我已经检查了每件事反复,似乎没有任何问题,在代码或逻辑。
代码如下:
var content = new FormUrlEncodedContent(new Dictionary<string, string>
{
{"grant_type", "authorization_code"},
{"code", code},
{"redirect_uri", redirectUri.ToString()},
{"client_id", clientId},
{"client_secret", clientSecret}
});
string token = string.Empty;
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));
var response = client.PostAsync(tokenEndpoint, content);
var responseContent = response.Result.Content.ReadAsStringAsync();
token = responseContent.ToString();
if (!response.Result.IsSuccessStatusCode) ;
}
return token;
我得到了一个错误:
"error": "redirect_uri_mismatch",
"error_description": "Bad Request"
以上页面的Url为:
http://localhost:62188/dashboard/googleSync.aspx
在Google控制台中,我将此Url作为授权返回Url:
那我还缺什么?