Ich habe GoogleAuthorizationCodeFlow Szenario von google api client dotnet und Tutorial implementiert, um Token von dem, was mein Client an den Server als Code gesendet. aber wenn ich flow.ExchangeCodeForTokenAsync
nennen, bekomme ich folgende Fehlermeldung:google ExchangeCodeForTokenAsync invalid_grant in webapi
{"Error:\"invalid_grant\", Description:\"\", Uri:\"\""}
Ich las google authorization invalid_grant und gusclass oauth 2 using google dotnet api client libraries aber sie haben mir nicht helfen und. Ich denke, es muss sehr einfach sein, aber ich weiß nicht, warum es nicht funktioniert. Für Client-Seite habe ich verwendet Satellizer und dies ist mein Server Codes:
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;
}
, was ist das Problem?
Können Sie den Code bitte einfügen? –