Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh Token not getting generated #418

Closed
davidh07 opened this issue Jul 1, 2022 · 2 comments
Closed

Refresh Token not getting generated #418

davidh07 opened this issue Jul 1, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@davidh07
Copy link

davidh07 commented Jul 1, 2022

Describe the bug:
Using the code from https://github.com/googleads/google-ads-dotnet/tree/main/Google.Ads.GoogleAds/examples/Authentication/GenerateUserCredentials
I am not getting the RefreshToken: Here is the results of Token Value after UserCredential credential = task.Result;
Name Value Type
AccessToken "Hidden Value XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" string
ExpiresInSeconds 3599 long?
IdToken null string
Issued {6/30/2022 9:08:46 PM} System.DateTime
IssuedUtc {7/1/2022 2:08:46 AM} System.DateTime
RefreshToken null string
Scope https://www.googleapis.com/auth/adwords string
TokenType "Bearer" string

Steps to Reproduce:
Please provide a code snippet or steps to consistently reproduce the experienced behavior.
[DO NOT INCLUDE ANY PERSONAL OR SENSITIVE DATA IN YOUR SUBMITTED CODE]

Expected behavior:

Client library version and API version:
Client library version: Latest Copy of code from https://github.com/googleads/google-ads-dotnet/tree/main/Google.Ads.GoogleAds/examples/Authentication/GenerateUserCredentials
Google Ads API version: Latest
.NET version: 4.8
Operating system (Linux, Windows, ...) and version (if the bug is platform-specific): Windows

Request/Response Logs:

Anything else we should know about your project / environment

@davidh07 davidh07 added the bug Something isn't working label Jul 1, 2022
@AnashOommen
Copy link
Member

@davidh07 I am fairly sure this is the same problem as the one in #332.

Try modifying the code example like this:

var initializer = new GoogleAuthorizationCodeFlow.Initializer
{
    ClientSecrets = secrets,
    Prompt = "consent",
};


// Authorize the user using desktop flow. GoogleWebAuthorizationBroker creates a
// web server that listens to a random port at 127.0.0.1 and the /authorize url
// as loopback url. See https://github.com/googleapis/google-api-dotnet-client/blob/main/Src/Support/Google.Apis.Auth/OAuth2/LocalServerCodeReceiver.cs
// for details.
Task<UserCredential> task = GoogleWebAuthorizationBroker.AuthorizeAsync(
    initializer,
    new string[] { GOOGLE_ADS_API_SCOPE },
    string.Empty,
    CancellationToken.None,
    new NullDataStore()
);
UserCredential credential = task.Result;

@AnashOommen AnashOommen self-assigned this Jul 11, 2022
@AnashOommen
Copy link
Member

This was fixed in 13.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants