我已经从google api 客户端 dotnet和教程实现了 GoogleAuthorizationCodeFlow场景,以从我的客户端作为代码发送到服务器的内容中获取令牌。但是当我打电话时,我收到以下错误:flow.ExchangeCodeForTokenAsync
{"Error:\"invalid_grant\", Description:\"\", Uri:\"\""}
我使用 google dotnet api 客户端库阅读了google 授权 invalid_grant和gusclass oauth 2,但它们并没有帮助我。我认为它一定很简单,但我不知道为什么它不起作用。对于客户端,我使用了 Satellizer,这是我的服务器代码:
public bool PostExchangeAccessToken(GoogleClientAccessCode code)
{
string[] SCOPES = { "email" };
IAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
{
ClientSecrets = new ClientSecrets()
{
ClientSecret = "******",
ClientId = "********.apps.googleusercontent.com"
},
Scopes = SCOPES
});
try
{
TokenResponse token;
token = flow.ExchangeCodeForTokenAsync("*****@gmail.com", Newtonsoft.Json.JsonConvert.SerializeObject(code), "https://localhost:44301/",
CancellationToken.None).Result;
}
catch (Exception ex)
{
throw ex;
}
return true;
}
问题是什么?