我正在使用以下代码,并为响应变量获取了invalid_grant status 400错误。
string url = string.Format("https://api.tdameritrade.com/v1/oauth2/token");
RestClient client = new RestClient(url);
RestRequest postRequest = new RestRequest(Method.POST);
postRequest.AddHeader("cache-control", "no-cache");
postRequest.AddHeader("content-type", "application/x-www-form-urlencoded");
postRequest.AddParameter("application/x-www-form-urlencoded", "grant_type=refresh_token&access_type=offline&refresh_token=kf6...E&client_id=AMNE...@AMER.OAUTHAP&redirect_uri=http://localhost", ParameterType.RequestBody);//, ParameterType.RequestBody)
// execute the request
IRestResponse response = client.Execute(postRequest);
使用https://developer.tdameritrade.com/authentication/apis/post/token-0时,状态200的值与postRequest.AddParameter的值相同。
我正在使用Visual Studio for Windows