我已经反复检查了每件事,似乎在代码或逻辑上没有任何问题。
代码如下:
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"
上一页的网址为:http://localhost:62188/dashboard/googleSync.aspx
在Google控制台中,我将此URL作为授权返回URL:
那我在这里想念什么?
答案 0 :(得分:0)
好:必须使用::redirect_uri =“ postmessage”,它才能起作用。