[英]Error "invalid_grant / Invalid JWT Signature." to get the access token using Oauth
[英]Can't get soundcloud access_token using php sdk. invalid_grant error
我正在使用soundcloud php sdk。 当我使用SDK进行跟踪时,它可以成功运行。 但是,当我尝试获取访问令牌以便使用它时,sdk会向我发送错误401。调试错误消息后,我得到了下面的responseJSON:{“ error”:“ invalid_grant”}
这是我的代码,我使用Zend框架
$code = $this->getRequest()->getParam('code',false);
if($code){
$client = new Services_Soundcloud($this->soundcloud['client_id'],$this->soundcloud['secret_key']);
try {
$access_token = $client->accessToken($code);
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
exit($e->getMessage());
}
}
有谁知道如何解决这个错误?
为了交换访问令牌的代码,您必须使用客户端ID,客户端密码和重定向uri实例化Services_Soundcloud
实例。 假设您将重定向uri存储在$this->soundcloud
,以下代码应该可以工作:
$client = new Services_Soundcloud(
$this->soundcloud['client_id'],
$this->soundcloud['secret_key'],
$this->soundcloud['redirect_uri']
);
$code = $this->getRequest()->getParam('code',false);
if ($code) {
try {
$access_token = $client->accessToken($code);
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
exit($e->getMessage());
}
}
让我知道是否可以解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.