Google Business Profile API n8n setup without gmail account

Hi,

i’m trying to connect a client to a n8n automation that responds to client reviews of their businessess. The problem is that since i don’t have access to their gmail account i can’t sign in after i’ve created the Client Oauth credentials ( with their account through sharing screen ).

I have the option of going there and initiating the account wich would grant me access for 7 days, after that this message appears:

The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.

How can I avoid the problem and not have to sign in again with their gmail account ( wich fixes that problem but I can’t be doing that every week )?

Is there any way of maybe doing HTTP requests to get a new token every time so it doesn’t expire, of course the google business profile api credential doesn’t have a place for a refresh token so doing an http request is what I think would let me have the same result as the api but be able to include the refresh token obtained in an http.

Thanks in advance.

Marc

Information on your n8n setup

  • **n8n version: 1.82.1 (Latest Stable)
  • **n8n EXECUTIONS_PROCESS setting (default: own, main): Schedule trigger wich activates twice a day and then i’m using the google business profile api ( get many reviews ) Planing to change from api to HTTP request.
  • **Running n8n via (Docker, npm, n8n cloud, desktop app): I’m using n8n cloud

Hey @Marc_Egido,

There are two options:

  1. Use his account
    Publish the app in your Google Cloud Console, log into the GMail account in your browser and add the credentials in your n8n. That way n8n handles the OAuth process and the credential never exepires.

  2. Authorize his account in your app
    In your app add the scopes you need for managing the Gmail account and go through the verification process (it’s boring and takes time).

    After that build an OAuth link for your client to authorize your access.
    The OAuth link looks something like this (I’ve asked ChatGPT to build mine):

    https://accounts.google.com/o/oauth2/v2/auth?client_id=393453627754-pueq9ho3nm345jko9kqhvellph9ugh0au.apps.googleusercontent.com&redirect_uri=YOUR_N8N_WEBHOOK_URL&response_type=code&scope=https://www.googleapis.com/auth/yt-analytics.readonly&access_type=offline&prompt=consent&approval_prompt=force
    

    You will receive a code like this in your webhook:

    That code can then be used to request the token.

    You will receive a token valid for 1h and the a refresh token used to request a new one, valid for another hour.

    You would have to build a logic to manage those tokens in your backend. Always storing the current token and the refresh token.

For more information please refere to Google APIs docs and always ask ChatGPT! It saved my life on this challenge hahaha.

:point_right: If my reply answers your question, please remember to mark it as a solution.

1 Like

I did the solution you mention in number 1 already with another account but it ended up getting expired, is there any way this is possible having done what you mention? Probably i did something wrong.

Thanks for your resposne!

How long later did it expire? What error did you encounter?

I believe, typically, as long as the creds are in use, they auto refresh, but if unused for long periods, could expire. Google also now incorporates total limits on some creds as well, even with auto refresh, they will need to be reconnected after 6-12 months (in some cases)

You have to publish the app.
Leaving the app in Test Mode makes the API key expire.

I’ll try, i think it’s probably beacuse i didn’t sign in again after publishing the app, hope it works!

Thanks

1 Like

Yeah! That’s probably the case. I use Google OAuth a lot and after publishing the app I don’t have to renew the credentials.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.