New token for existing Console Application

81 views
Skip to first unread message

Olayinka Popoola

unread,
Feb 14, 2024, 4:21:52 AM2/14/24
to Google Ads API and AdWords API Forum
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.

Google Ads API Forum Advisor

unread,
Feb 14, 2024, 9:04:45 AM2/14/24
to ayotade...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

I see that you have already raised this concern on another thread with the subject “Error: Operation is not implemented, or supported, or enabled” and we have already responded there for this issue. To avoid multiple threads on the same issue, please take a look at that thread and continue the discussion on the same for further updates on the issue.

 
This message is in relation to case "ref:!00D1U01174p.!5004Q02rz6Eg:ref"

Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages