【问题标题】:invalid_grant trying to get OpenID Connect token from PayPalinvalid_grant 尝试从 PayPal 获取 OpenID Connect 令牌
【发布时间】:2017-06-04 12:49:45
【问题描述】:

我正在关注Guide: Integrate Log In with PayPal,试图让它在 WordPress 4.7.1 上运行。我已成功嵌入使用 PayPal 登录按钮。点击它带来登录,然后重定向到“returnurl”。

我目前正试图将在上一步中收到的授权代码传递给 tokenservice 端点以接收访问令牌。

我的“returnurl”有这个 curl 代码(由 Guide: grant token from authorization code 建议):

<?php

$curl = curl_init( 'https://api.sandbox.paypal.com/v1/identity/openidconnect/tokenservice' ); 
// not $curl = curl_init( 'https://api.sandbox.paypal.com/v1/oauth2/token' ); 
curl_setopt( $curl, CURLOPT_POST, true );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1);
$code = $_GET['code'];  // The code from the previous request
$redirect_uri = 'http://xxxxxx.contemplate.me.ke/';

curl_setopt( $curl, CURLOPT_POSTFIELDS, array(
    'redirect_uri' => $redirect_uri,
    'grant_type' => 'authorization_code',
    'code' => $code
) );

curl_setopt( $curl, CURLOPT_USERPWD,
    "My-Client-Id" . ":" . 
    "My-Secret");

$auth = curl_exec( $curl ); 
print '$auth = ';print_r($auth); // to see the error
$secret = json_decode($auth); 
$access_key = $secret->access_token;
?>

登录后我从中得到的只是:

$auth = {"error_description":"Grant type is null","error":"invalid_grant","correlation_id":"0f5787fc6413f","information_link":"https://developer.paypal.com/docs/api/#errors"}

我做错了什么?

【问题讨论】:

    标签: php wordpress curl paypal login


    【解决方案1】:

    我刚刚发现 How to Implement User Log-in with PayPal 使用 GET 而不是 POST 并且它有效!我得到了我的令牌。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-08
      • 1970-01-01
      • 1970-01-01
      • 2017-06-21
      • 2021-10-12
      • 2023-03-18
      相关资源
      最近更新 更多