Implémente le rafraichissement d'un Token Google

main
Paul Schneider 8 years ago
parent 629d87e7a6
commit 6895c19238
1 changed files with 17 additions and 0 deletions

@ -143,6 +143,23 @@ namespace Yavsc.Helpers
return result.ToArray();
}
public static async Task<TokenResponse> RefreshToken(TokenResponse oldResponse)
{
string ep = " https://www.googleapis.com/oauth2/v4/token";
// refresh_token client_id client_secret grant_type=refresh_token
try {
using (var m = new SimpleJsonPostMethod(ep)) {
return await m.Invoke<TokenResponse>(
new { refresh_token= oldResponse.RefreshToken, client_id=Startup.GoogleSettings.ClientId,
client_secret=Startup.GoogleSettings.ClientSecret,
grant_type="refresh_token" }
);
}
}
catch (Exception ex) {
throw new Exception ("Quelque chose s'est mal passé à l'envoi",ex);
}
}
}
}

Loading…