尝试获取 eBay 刷新令牌

问题描述 投票:0回答:1

我正在构建一个应用程序,它利用 eBay 的 Buy API 来检索有关当前列出的产品的信息。我的问题是,我获取的访问令牌每 2 小时就会过期,我需要刷新令牌来自动生成新的访问令牌。我正在尝试获取刷新令牌,但遇到以下 API 端点的问题:

端点:https://api.ebay.com/identity/v1/oauth2/token

我需要传递以下五个参数:

HTTP 标头:

Content-Type = application/x-www-form-urlencoded
Authorization = Basic <B64-encoded-oauth-credentials>
Request body (wrapped for readability):
grant_type=authorization_code
code=<authorization-code-value>
redirect_uri=<RuName-value>

我正在使用 Postman 进行此 API 调用,并且我已仔细检查并确认所有参数均已正确设置。但是,我不断收到以下错误:

{
    "error": "invalid_request",
    "error_description": "request is missing a required parameter or malformed."
}

我花了两个多小时试图解决这个问题,但没有成功。有人可以提供有关如何正确构建此请求或识别可能导致此错误的任何潜在问题的指导吗?

ps:我可以通过

grant_type=client_credentials

获取我的访问令牌
node.js authentication access-token ebay-api
1个回答
0
投票

需要检查的一些事项: 您是否选中了 eBay developer token settings page 上的“OAuth Enabled”复选框? https://developer.ebay.com/my/auth/?env=product&index=0&auth_type=oauth

您是否在授权标头中的“Basic”一词和编码凭据之间添加了空格?另请确保在 client_id 和 client_secret 之间放置冒号“:”。我建议使用 Postman 内置的基本身份验证处理。

确保“body”选项设置为“x-www-form-urlencoded”。这将为您添加“Content-Type”标头。最后,确保您的授权码尚未过期。它的有效期只有大约5分钟。我让它在 Postman 中工作,附上一些屏幕截图来帮助: enter image description here enter image description here enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.