Posts tagged with google-api-dotnet-client

I have a project whose Publishing status is Testing (I am using Google Ads Api).

            using FileStream stream = new("Credentials.json", FileMode.Open, FileAccess.Read);             // The file token.json stores the user's access and refresh tokens, and is created             // automatically when the authorization flow completes for the first time.             UserCredential credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(              GoogleClientSecrets.FromStream(stream).Secrets,              scopes,              "user",              CancellationToken.None,              new FileDataStore("Token", true)             );             if (credential.Token.IsExpired(credential.Flow.Clock))                 await credential.RefreshTokenAsync(CancellationToken.None); 

When I use the code above, it expects me to log in via Gmail, but I want to automatically handle the Refresh token and continue uninterrupted requests without understanding anything to the user. I am using Desktop Application as Flow, but I am using Net 5 Api as Framework. I look forward to your help in this matter.

Thank you from now.