【问题标题】:paypal authorization unsupported_grant_type Grant Type is NULL in axios post requestpaypal 授权 unsupported_grant_type 授权类型在 axios 发布请求中为 NULL
【发布时间】:2020-07-17 01:43:00
【问题描述】:

我正在尝试将 paypal 集成到我的应用中,但出现 400 错误 [unsupported_grant_type] Grant Type is NULL

axios
      .post(
        'https://api.sandbox.paypal.com/v1/oauth2/token',
        { grant_type: 'client_credentials' },
        {
          headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
          },
          auth: {
            username:
              'clientId',
            password:
              'secret'
          }
        }
      )
      .then(response => {
        console.log('response', response.data);

      })
      .catch(err => {
        // console.log('error', { ...err });
        console.log('error', err);
      });

我做错了什么?

注意:在邮递员中可以正常工作

【问题讨论】:

    标签: api react-native paypal axios


    【解决方案1】:

    我找到了解决办法..

    字符串化身体..

    添加

    const qs = require('querystring');
    qs.stringify({ grant_type: 'client_credentials' })
    

    【讨论】:

    • 您不需要什么,只需将其添加到 url: ?grant_type=client_credentials ,然后不带正文发送
    猜你喜欢
    • 2019-05-21
    • 2020-02-11
    • 2020-01-19
    • 2021-01-09
    • 1970-01-01
    • 1970-01-01
    • 2022-08-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多