首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何解决易趣( [error] => invalid_client [error_description] =>客户端认证失败)

如何解决易趣( [error] => invalid_client [error_description] =>客户端认证失败)
EN

Stack Overflow用户
提问于 2020-01-01 15:03:11
回答 2查看 2.1K关注 0票数 2
代码语言:javascript
运行
复制
public function authorizationToken(){
$link = "https://api.ebay.com/identity/v1/oauth2/token";
$codeAuth = base64_encode($this->clientID.':'.$this->certID);
$ch = curl_init($link);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded','Authorization: Basic '.$codeAuth));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=authorization_code&code=".urlencode($this->authCode)."&redirect_uri=".$this->ruName."&scope=".urlencode('https://api.ebay.com/oauth/api_scope'));
$response = curl_exec($ch);
$json = json_decode($response, true);$info = curl_getinfo($ch);
curl_close($ch);print_r($json);}
EN

回答 2

Stack Overflow用户

发布于 2020-01-05 11:38:55

看起来你把refresh_tokenauthorization_token搞混了,因为你在两个不同的请求中混合了不兼容的参数。

如果你正在尝试获取初始的"AccessToken“(也就是UserAccessToken,access_token,AuthToken,...),那么你应该在你的请求体中包含scope参数。因此,您的请求正文应如下所示:

代码语言:javascript
运行
复制
grant_type=authorization_code&redirect_uri=<redirect_uri>&code=<authorization_code>

其中,<authorization_code>是从here返回的值。

要了解不同之处,我会在这个主题上推荐this answer而不是official docs

票数 1
EN

Stack Overflow用户

发布于 2020-01-01 15:32:19

试试这段代码

代码语言:javascript
运行
复制
  public function authorizationToken(){
    $link = "https://api.ebay.com/identity/v1/oauth2/token";
    $codeAuth = base64_encode($this->clientID.':'.$this->certID);
    $ch = curl_init($link);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded','Authorization: Basic '.$codeAuth));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials&scope=".urlencode('https://api.ebay.com/oauth/api_scope'));
    $response = curl_exec($ch);
    $json = json_decode($response, true);
    $info = curl_getinfo($ch);
    curl_close($ch);
    print_r($json);
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59550592

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档