This is an existing console application that used  Adwords to generate its 
refresh token. Since Adword is deprecated,

Below is my static function to generate new refresh token:
public async static Task UserAuth()
 {
     string id = "xxxxxxxxx.apps.googleusercontent.com";
     string secret = "xxxxxxxxxxxx";
     ClientSecrets secrets = new ClientSecrets()
     {
         ClientId = id,
         ClientSecret = secret
     };
     string[] scopes = { "https://www.googleapis.com/auth/adwords"; };

    
    
         var flow = new GoogleAuthorizationCodeFlow(new 
GoogleAuthorizationCodeFlow.Initializer
         {
             ClientSecrets = secrets,
             Scopes = scopes,
             DataStore = new FileDataStore("GoogleAdsTokenStore")
         });


         var authCodeUri = 
flow.CreateAuthorizationCodeRequest("urn:ietf:wg:oauth:2.0:oob").Build();
         Console.WriteLine("Authorize the application by visiting the 
following URL:");
         Console.WriteLine(authCodeUri.AbsoluteUri);
         Console.WriteLine("Enter the authorization code:");

         // Read the authorization code from the console
         string code = Console.ReadLine();

         // Exchange the authorization code for tokens
         var token = await flow.ExchangeCodeForTokenAsync("user", code, 
"urn:ietf:wg:oauth:2.0:oob", CancellationToken.None);

         // Output the token information
         Console.WriteLine("Access token: " + token.AccessToken);
         Console.WriteLine("Refresh token: " + token.RefreshToken);
         Console.WriteLine("Token expires at: " + token.ExpiresInSeconds);
     //}


 }

The above function return a URL string which is blocked. 

Please remember, it is a console application.

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/83a2319d-480e-41ad-93f9-85ab03d0f43cn%40googlegroups.com.

Reply via email to