【问题标题】:Paypal API with angularjs带有 angularjs 的 Paypal API
【发布时间】:2016-09-05 12:28:40
【问题描述】:

我正在使用 Angular-JS 开发的电子商务解决方案的上下文中进行 PayPal API 调用。我能够使用以下代码从 PayPal 取回 auth_token。 我的代码:

var basicAuthString = btoa('AUAlrIhHNoiQlmaW.............:EJk......');
         $http({

         url: 'https://api.sandbox.paypal.com/v1/oauth2/token',
         method: 'POST',
         headers: {
             'Accept': 'application/json',
             'Content-Type': 'application/x-www-form-urlencoded',
             'Authorization': 'Basic ' + basicAuthString,
         }, 
                 data: { 'grant_type': 'client_credentials' }
         }).success(function (data, status, headers, config) {
                     console.log(data)
         }).error(function (error) {
             console.log("erreur "+error);
         });

发送数据时,我收到一个错误

error:{"error":"unsupported_grant_type","error_description":"Grant Type is NULL"}

【问题讨论】:

    标签: angularjs curl paypal oauth-2.0


    【解决方案1】:

    您应该像这样发送授权类型:

     data: 'grant_type=client_credentials'
    

    【讨论】:

      猜你喜欢
      • 2010-10-17
      • 2011-05-28
      • 2019-02-28
      • 2016-01-25
      • 2015-04-07
      • 2013-03-21
      • 1970-01-01
      • 2022-08-02
      • 2013-03-06
      相关资源
      最近更新 更多