I have problem using GoogleWebAuthorizationBroker.AuthorizeAsync
to authenticate, and looking at some other questions here I went for GoogleAuthorizationCodeFlow
. The thing is to use this method I need to get the refresh token.
I have manage to do that following the steps given in this answer, but I haven't find a way of replicating this steps from inside the code in c#.
Is there some way of getting a refresh token and access token using the Google Api?
This is where I need to use it:
ClientSecrets clientSecrets = new ClientSecrets();
clientSecrets.ClientId = id;
clientSecrets.ClientSecret = secret;
String scope = StorageService.Scope.CloudPlatform;
var token = new TokenResponse { RefreshToken = "???" };
var credentials = new UserCredential(new GoogleAuthorizationCodeFlow(
new GoogleAuthorizationCodeFlow.Initializer
{
ClientSecrets = clientSecrets
}),
"user",
token);
storageService = new StorageService(new BaseClientService.Initializer()
{
HttpClientInitializer = credentials,
ApplicationName = app,
});