Closed davidh07 closed 2 years ago
@davidh07 I am fairly sure this is the same problem as the one in https://github.com/googleads/google-ads-dotnet/pull/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;
This was fixed in 13.0.0.
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