My Business
2.2K members online now
2.2K members online now
For developers who are using the Google My Business API to manage locations
Guide Me
star_border
Reply

Getting Error:"invalid_grant" from last few days

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi Team,

 

We are using GMB API v3 for C# in our application. We are creating locations in GMB whenever new store is created in out CMS application. But from last few days (From 20th July 2017) i am getting Error:"invalid_grant" and not updating anything in GMB. Please let me know what are the steps to resolve the issue.

 

Regards,

Karthik Jilla

1 Expert replyverified_user

Re: Getting Error:"invalid_grant" from last few days

Google Employee
# 2
Google Employee

Hi @WAS S,

 

When using the OAuth 2.0 client ID for authorization, you should store the refresh token for future use and use the access token to access the API. Once the access token expires, the application should use the refresh token to obtain a new one. This way, your application will always be able to request a new access token when necessary. This process requires a user to manually authorize the application only once.

 

Thanks,

Shalini, The Google My Business API team

Getting Error:"invalid_grant" from last few days

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi Shalini,

 

Thanks for the reply. As you said this process requires a user manually authorize the application. So can you please tell me how do it in detail. 

 

And also as you said we are storing the refresh token but not using the access token in the application. Below is my code snippet. Please check and let me know if any changes required.

 

public UserCredential GetCredentials()
{
UserCredential OAUth2Credential = null;
try
{
ClientSecrets secrets = new ClientSecrets()
{
ClientId = "xxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
ClientSecret = "xxxxxxxxxxxxxx"

};

var token = new TokenResponse { RefreshToken = "D/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" };

OAUth2Credential = new UserCredential(new GoogleAuthorizationCodeFlow(
new GoogleAuthorizationCodeFlow.Initializer
{
ClientSecrets = secrets
}),
"was_support@adidas-group.com",
token);

return OAUth2Credential;
}
catch (Exception ex)
{
string str = ex.Message;
return OAUth2Credential;
}
}

 

Regards,

Karthik Jilla