2

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,
            });
Community
  • 1
  • 1
moondaisy
  • 4,303
  • 6
  • 41
  • 70
  • have you seen [this example](http://stackoverflow.com/questions/10827920/not-receiving-google-oauth-refresh-token) I think this is relative to what you are seeking. – alphamalle Aug 16 '16 at 19:33
  • that is what i'm doing from command line to get the token, but I don't know what I need to do to get the same result using [this](https://developers.google.com/api-client-library/dotnet/apis/oauth2/v2) – moondaisy Aug 16 '16 at 20:22
  • @moondaisy any solution for this? – Yusril Maulidan Raji May 14 '18 at 13:02

0 Answers0