400 Bad Request invalid_grant

2022-11-02 Thread 'Amol Kawale' via Google Ads API and AdWords API Forum
Hello Team,

We try to execute get keyword suggestion API & locations API in google ads 
but we getting the following issues:

*Fatal error*: Uncaught GuzzleHttp\Exception\ClientException: Client error: 
`POST https://oauth2.googleapis.com/token` resulted in a `400 Bad Request` 
response: { "error": "invalid_grant", "error_description": "Token has been 
expired or revoked." } 

I tried to generate refresh token as well but it giving me error as follows:
https://prnt.sc/Um0nYXn2gG_j

Pls help to fix me.

Regards,
Amol

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/9a2bc4bc-3d97-4e71-ba16-4c9335bd92dfn%40googlegroups.com.


400 Bad Request Invalid_grant

2021-02-04 Thread abadariki temidayo

Hello i requested auth using the below api and i granted access when the 
consent screen came up and a code was displayed which i was told to copy:

https://accounts.google.com/o/oauth2/auth?client_id={Your Client 
ID}_type=code=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fadwords_uri=urn:ietf:wg:oauth:2.0:oob_type=offline_prompt=auto

Response:
Please copy this code, switch to your application and paste it there:
4/1AY0e-g4VZGxW_q7aeMGPlyUDeC9DThgsne-sYE3Jsp6SKlZu03lj7xm7mqs

Now: i tried calling this API to get accesss token

 var params = {
"code": "4/1AY0e-g57KkT4es9IIZHLO3p1ZQSbo8d2AdbOCaQw8lbV0iNYaycwG0ZodUU",
"client_id": 
"***88-m01spevhl0o1gq8vluba9mo4ioj3fkuq.apps.googleusercontent.com",
"client_secret": "--**",
"redirect_uri": "urn:ietf:wg:oauth:2.0:oob",
"response_type": "offline",
"grant_type": "authorization_code"

  }

  const { data } = await axios({
url: 'https://accounts.google.com/o/oauth2/token',
method: 'post',
params: params,
  });


 Response:

{
  "error": "invalid_grant",
  "error_description": "Bad Request"
}


Please how do i solve this problem ?

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/73e15af8-1ec0-47fc-80b3-4a422a8ab640n%40googlegroups.com.


RE: 400 Bad Request: invalid_grant

2020-09-08 Thread Google Ads API Forum Advisor Prod
Hello,

Thanks for reaching out! Can you please elaborate on the issue you are facing 
along with what you are requesting to the API? In order for me to take a closer 
look, can you also please provide the complete request and response logs along 
with your customerClientId via the Reply privately to author option? Please see 
this guide on how to enable logging.

Regards,

Danica
Google Ads API Team
ref:_00D1U1174p._5004Q24ZSo7:ref

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/9e19f0QGCY7N00VHjyKZjVRoaaVIAr2bhlhA%40sfdc.net.


400 Bad Request: invalid_grant

2020-09-07 Thread Андрей Ласевичев
Hello!

The reasons why you may receive an error:
POST https://www.googleapis.com/oauth2/v4/token` resulted in a `400 Bad 
Request` response:
{
  "error": "invalid_grant",
  "error_description": "Bad Request"
}

Appears selectively. Someone POPs up, someone without errors.
I noticed that the token is always returned. An attempt to use it results 
in this error.

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/b1d6c6ac-0116-4c76-9631-021075385a24n%40googlegroups.com.


Re: Google AdWords API 400 "Bad Request" "invalid_grant" error: is it possible for refresh_token to be expired?

2020-04-15 Thread Google Ads API Forum Advisor Prod
Hello,

Unfortunately, my team doesn't have any insight into why a refresh token may 
have been revoked. If it stopped working unexpectedly, it's most likely because 
the user either revoked it or generated a new one for some other purpose which 
brought them over the limit of maximum simultaneous refresh tokens.

If you're using a flow where users have to sign in to access their account 
through your service (which is what it sounds like, based on your description), 
you should just build in a way for them to re-authenticate if things go wrong.

Regards,
Mike, Google Ads API Team
ref:_00D1U1174p._5001UZXKqw:ref

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/2798L0Q8UAR600TNMpXcW1R22__QWTSxZx8A%40sfdc.net.


Re: Google AdWords API 400 "Bad Request" "invalid_grant" error: is it possible for refresh_token to be expired?

2020-04-15 Thread Google Ads API Forum Advisor Prod
Hello,

I am checking on this internally within the team and will provide you with 
updates once we have more insight.

Thanks,
Danica Calusin, Google Ads API Team
ref:_00D1U1174p._5001UZXKqw:ref

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/Ac9lQ0Q8U91Z00_B3cPSbNS5epy_9ECXAyqg%40sfdc.net.


Re: Google AdWords API 400 "Bad Request" "invalid_grant" error: is it possible for refresh_token to be expired?

2020-04-14 Thread Zweitze
I know a few circumstances where an Refresh Token expires, or becomes 
invalid:

1. Your software revoked the token 
.
 
In other words, your software has a Logout function and that was 
successfully called.
2. That user went to his Google account settings, Security, and then Manage 
third party access (direct link ). 
He saw your OAuth2 client (here called "third party app", clicked on it, 
and then clicked "Remove Access".
3. The Refresh token expired because it was not used in six months. By 
usage, it means obtaining an access token using that particular Refresh 
token.
4. The user granted your OAuth2 client over 50 times access, without 
logging out in between. For instance, you have a web application storing 
the refresh token in a cookie, and the user destroys his cookies every now 
and when. Because of that, he has to log in because the old tokens were 
never revoked. Now, if you also use that same OAuth2 client in an app, then 
at one point the refresh token for that app will become invalid.
5. The most likely reason: the requested OAuth2 scope was not limited to 
adwords, it also contained one or more gmail scopes. In that case, when a 
user changes his password, all refreshtokens with a gmail scope become 
invalid.

Reasons 2 to 5 are documented at the Google OAuth2 docs 
.

A few years ago I noticed that the last reason was incomplete. You get the 
same behaviour if a Google Analytics scope is included. I am not sure if 
this is still the case, this behaviour has never been officially documented.

When you do get to the bottom of it, please post your findings!


On Friday, April 10, 2020 at 10:28:18 PM UTC+2, adsapiforumadvisor wrote:
>
> Hi Petro,
>
> As mentioned in this 
> 
>  documentation, 
> refresh tokens do not expire. In order for me to further investigate what 
> has caused your issue, kindly provide your client customer ID and complete 
> detailed request and response logs. Please ensure that you *"Reply 
> privately to author" *when providing this information,
>
> Thanks,
> Danica Calusin, Google Ads API Team
>
> ref:_00D1U1174p._5001UZXKqw:ref
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/c257d3f9-594e-47a1-9316-00bcd5143018%40googlegroups.com.


Re: Google AdWords API 400 "Bad Request" "invalid_grant" error: is it possible for refresh_token to be expired?

2020-04-14 Thread Zweitze
I know a few circumstances where an Refresh Token expires, or becomes 
invalid:

1. Your software revoked the token 
<https://developers.google.com/identity/protocols/oauth2/native-app#tokenrevoke>.
 
In other words, your software has a Logout function and that was 
successfully called.
2. That user went to his Google account settings, Security, and then Manage 
third party access (direct link <https://myaccount.google.com/permissions>). 
He saw your OAuth2 client (here called "third party app", clicked on it, 
and then clicked "Remove Access".
3. The Refresh token expired because it was not used in six months. By 
usage, it means obtaining an access token using that particular Refresh 
token.
4. The user granted your OAuth2 client over 50 times access, without 
logging out in between. For instance, you have a web application storing 
the refresh token in a cookie, and the user destroys his cookies every now 
and when. Because of that, he has to log in because the old tokens were 
never revoked. Now, if you also use that same OAuth2 client in an app, then 
at one point the refresh token for that app will become invalid.
5. The most likely reason: the requested OAuth2 scope was not limited to 
adwords, it also contained one or more gmail scopes. In that case, when a 
user changes his password, all refreshtokens with a gmail scope become 
invalid.

Reasons 2 to 5 are documented at the Google OAuth2 docs 
<https://developers.google.com/identity/protocols/oauth2#expiration>.

A few years ago I noticed that the last reason was incomplete. You get the 
same results if an Google Analytics token is included. I am not sure if 
this is still the case, this behaviour has never been officially documented.

When you do get to the bottom of it, please post your findings!





On Friday, April 10, 2020 at 4:56:53 PM UTC+2, Casual Stone wrote:

> Hello. We store refresh tokens per user retrieved after OAUTH 2 
> authentication. We use refresh_token to fetch access_token if it is 
> expired. But recently I noticed that some of our customers get 400 "Bad 
> Request" "invalid_grant" error. While investigating the issue I noticed 
> that refresh_token was expired (or broken), but if you authenticate again 
> you get a new one, and everything starts working again.
> So my question — is it possible for refresh_token to be expired? Or Google 
> just changed recently the way token was generated? Or maybe we 
> unintentionally corrupted refresh_tokens somehow in our database?
>
> Kind Regards,
> Petro
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/ded3837b-4e95-42ed-8af9-2d84d5ca50f4%40googlegroups.com.


RE: Google AdWords API 400 "Bad Request" "invalid_grant" error: is it possible for refresh_token to be expired?

2020-04-10 Thread Google Ads API Forum Advisor Prod
Hi Petro,

As mentioned in this documentation, refresh tokens do not expire. In order for 
me to further investigate what has caused your issue, kindly provide your 
client customer ID and complete detailed request and response logs. Please 
ensure that you "Reply privately to author" when providing this information,

Thanks,
Danica Calusin, Google Ads API Team
ref:_00D1U1174p._5001UZXKqw:ref

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/k-o7w0Q8LA6F00AZ_mNwXLQSqmi7XDcJRtZQ%40sfdc.net.


Google AdWords API 400 "Bad Request" "invalid_grant" error: is it possible for refresh_token to be expired?

2020-04-10 Thread Casual Stone
Hello. We store refresh tokens per user retrieved after OAUTH 2 
authentication. We use refresh_token to fetch access_token if it is 
expired. But recently I noticed that some of our customers get 400 "Bad 
Request" "invalid_grant" error. While investigating the issue I noticed 
that refresh_token was expired (or broken), but if you authenticate again 
you get a new one, and everything starts working again.
So my question — is it possible for refresh_token to be expired? Or Google 
just changed recently the way token was generated? Or maybe we 
unintentionally corrupted refresh_tokens somehow in our database?

Kind Regards,
Petro

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/7f3f9351-2a7b-4b29-b549-e86f6c63068a%40googlegroups.com.