share api refresh token across platform

26 views
Skip to first unread message

Pratik Gavand

unread,
Jul 31, 2024, 4:35:44 AM7/31/24
to Google Ads API and AdWords API Forum
HI - I am working on oauth changes. we have a web app with its own client id and client secret and we have andorid and ios with its own client id and secret. User can grant additional scopes in mobile that are visible in the user account on the google. However web app is not aware of the new scopes. So IOS tried to generate a auth code for server to retrieve a new api refersh token and access token using server client id. However when we try to invoke the token endpoint with the authcode it gives a bad request error. we want to be able to refresh api token that has information about the new scopes granted by user.

curl -X POST https://oauth2.googleapis.com/token \
-d "client_id=xxxxxx" \
-d "client_secret=xxxxxxx" \
-d "code=xxxxx" \
-d "grant_type=authorization_code" \
-d "redirect_url="


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

Google Ads API Forum Advisor

unread,
Jul 31, 2024, 10:06:03 AM7/31/24
to pga...@copper.com, adwor...@googlegroups.com
Hi,

Thank you for contacting the Google Ads API support team.

From the provided screenshot, I understand that you're encountering an "invalid_grant" error. According to the Google Ads API documentation, Google Cloud Platform project with an OAuth consent screen configured for an external user type and a publishing status of "Testing" is issued a refresh token expiring in 7 days. So if your Google project's publishing status is Testing so the refresh token expires every 7 days and receives an invalid_grant error. 

You can follow the following steps to avoid this issue:
  • Go to the Google API Console and navigate to the OAuth consent screen
  • Change the publishing status to “In production”

If the issue persists, please provide us with the complete API logs (request and response with request-id and request header) generated at your end so that we can better assist you.

If you are using a client library and haven't enabled the logging yet, I would request you to enable logging for the specific client library that you are using. You can refer to the guides Java, .Net, PHP, Python, Ruby or Perl to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag.

You can send the details via Reply privately to the author option, or direct private reply to this email.
 

This message is in relation to case "ref:!00D1U01174p.!5004Q02vEMH3:ref" (ADR-00260275)

Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages