1

I am able to get "code" from google during user authentication process. I am getting error when trying to get access token.

My Request Url is this

My Code for Fetch response

var request = WebRequest.Create(url);
request.Method = requestMethod;
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = 0;
WebResponse responseData = request.GetResponse();

Geting Exception at GetResponse() :

The remote server returned an error: (400) Bad Request

I am not able to figure out what I am missing in code. Please help me out here

4

1 回答 1

0

看起来您已经完成了第一步,现在有一个授权码,您正试图用它来交换访问令牌。

确保请求是 POST 并确保所有参数都在请求的正文中,而不是在查询字符串部分。由于看起来您使用的是 C#,请参阅Google Analytics API - Retrieve refresh token with OAuth2 & ASP.NET以了解看起来相同的问题和解决方案。

最后,请重置您的客户端密码,因为您已将其包含在上述问题的 URL 中。这可以通过 API 控制台完成:https ://code.google.com/apis/console/

于 2013-07-19T21:06:05.777 回答