Yahoo OAuth 2.0 - 无法检索访问令牌

时间:2015-04-07 06:42:44

标签: php api yahoo yahoo-api

我正在尝试实施Yahoo OAuth 2.0以将联系人导入我的应用程序。我使用PHP和本指南(服务器端应用程序部分):

https://developer.yahoo.com/oauth2/guide

我创建了我的应用,授权访问并接收我的代码

  

"授权码附加到redirect_uri,如下所示   代码= ABCDEF"

我已成功抵达第4步。 https://developer.yahoo.com/oauth2/guide/#step-4-exchange-authorization-code-for-access-token

在这里,我无法获得https://api.login.yahoo.com/oauth2/get_token的回复并收到我的访问令牌。

我正在使用https://github.com/saurabhsahni/php-yahoo-oauth2/blob/master/YahooOAuth2.class.php类。

这是我的代码:

include_once("/libraries/Yahoo/YahooOAuth2.class.php");

// step 1, step2, step3     
// Successfully received authorization code and stored in my session
[...]

//my Client ID (Consumer Key)    
$cc_key = 'x3485sdfsfsdfsdfsdf[..]';

//Client Secret (Consumer Secret)    
$cc_secret = '3423423fddssdfsdf';


//my authorization code receive    
$code = $_GET['code'];

define("CONSUMER_KEY",'$cc_key');
define("CONSUMER_SECRET",$cc_secret);
$redirect_uri="http://dev.example.com/user/register-step4";


$token=$oauth2client->get_access_token(CONSUMER_KEY,CONSUMER_SECRET,$redirect_uri,$code);

我收到401错误: "收到错误:401原始回复:{"错误":" invalid_grant"}"

来自yahoo api错误:

  

401 invalid_grant:提供了无效或过期的令牌。

这不是真的,因为我的授权代码应该是好的,因为我收到的内容与规范完全一样。

相关问题:

https://developer.yahoo.com/forum/Messenger-IM-SDK/not-getting-response-for-https-api-login-yahoo-com-oauth-v2-get-request-token/1310023528000-09714556-4cd3-38c5-b799-d29e8d5f9bcb/

0 个答案:

没有答案