我目前正在尝试获取一个小型应用来验证我自己的用户。
首先我导航到
https://auth.ebay.com/oauth2/authorize?
client_id=...&
response_type=code&
redirect_uri=...&
scope=...
要求我登录,然后通过url给我授权码。
我对此进行url解码,并使用邮递员通过点击以下内容来请求访问令牌:
https://api.ebay.com/identity/v1/oauth2/token
带有标题:
Authorization: Basic ...
Content-Type: application/x-www-form-urlencoded
这两种方法似乎都是正确的,因为如果我更改它们中的任何一个,我都会收到一条错误消息,指出它们是错误的。
在身体上
grant_type: authorization_code
redirect_uri: ...
code: ...
如果我将其更改为其他内容,再次将所有这些错误单独删除。
我得到的错误是:
{
"error": "invalid_grant",
"error_description": "the provided authorization grant code is invalid or was issued to another client"
}
对我来说这很奇怪。这使用与上一个请求相同的redirect_uri和client_id。
我尝试生成新的重定向url,尝试旋转客户端机密,尝试不对auth代码进行url解码,但是无论尝试如何,都会遇到相同的错误。
有趣的是,如果我请求的client_credentials的grant_type效果很好,但对我却没什么用。
我很困惑,ebay论坛也无济于事,任何帮助将不胜感激。
答案 0 :(得分:1)
我实际上已经设法解决了这个问题。
我正在使用js的encodeURI进行url解码,但实际上并未解码任何内容。切换到解码URIComponent,现在看来可以正常使用