为什么我对TDA API的API调用未返回刷新令牌?

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

因此,我按照信中的步骤进行操作:https://www.reddit.com/r/algotrading/comments/c81vzq/td_ameritrade_api_access_2019_guide/以获取刷新令牌,以便我可以使用C#构建客户端应用程序以使用TD Ameritrade的API,进行特殊的股票和期权筛选以及交易。在遇到任何麻烦之前,我走到了尽头。

在获取我的刷新令牌的最后一步,即您在https://developer.tdameritrade.com/authentication/apis/post/token-0上填写字段的过程失败,我只是在HTTP 401错误中得到以下响应:

HTTP/1.1 401 Unauthorized
Access-Control-Allow-Headers: origin
Access-Control-Allow-Methods:
GET
Access-Control-Allow-Origin:
https://developer.tdameritrade.com
Access-Control-Max-Age: 3628800
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 31
Content-Security-Policy: frame-ancestors 'self'
Content-Type: application/json;charset=UTF-8
Date: Sat, 04 Apr 2020 16:07:04 GMT
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Application-Context: OAUTH_SERVICE:run:8080
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block
{
  "error": "invalid_grant"
}

问题可能是什么?我已经对每个步骤和文本框中的值(如下图所示)进行了两次和三次检查,以获取刷新令牌,但是我无法使其正常工作。根据指南的步骤,代码和客户端ID也已正确完成-我已仔细检查过两次。

This doesn't work!

[我按照Reddit指南中的步骤以及TDA Ameritrade自己提供的链接指南中的步骤进行操作,以确保我将正确的值放在适当的字段中,所以我真的不知道发生了什么。

感谢您的任何帮助。

api oauth oauth-2.0 algorithmic-trading trading
1个回答
0
投票

事实证明,http://localhost不适用于TDA API中的重定向URI。您必须在应用程序设置中使用https://127.0.0.1,然后在尝试生成第一个刷新令牌时,在随后的许多步骤中再次使用。

所以,解决了这个问题。

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