Use Gmail Settings API with HTTP Make an OAuth 2.0 Request to get Signatures

I want to customize and setup dinamically a signature in a bunch of Google Workspace users

I look around a way to programmatically change from a module inside a scenario the signature of an email in gmail.
I find out that there is not a currently module that do that but I figue out that I can make an HTTP Make a OAuth 2.0 call to the right API. Following this guide I should make the right connection to with the right oAuth credentials.
Now I have to tell the module the right parameter for update this signature. I watch this video:

That shoudl explain the right wayt to do that in Python but I think that I can do also with Make even if I pass the right data to the module.
I try to start the module and it gives me an “OK - Success” but, after when I go to the gmail nothing change.
Can someone help me to figure out how to solve this issue?

Thanks

Welcome to the Make community!

1. Screenshots of module fields and filters

Please share screenshots of relevant module fields and filters in question? It would really help other community members to see what you’re looking at.

You can upload images here using the Upload icon in the text editor:
Screenshot_2023-10-07_111039

2. Scenario blueprint

Please export the scenario blueprint file to allow others to view the mappings and settings. At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.

Screenshot_2023-08-24_230826
(Note: Exporting your scenario will not include private information or keys to your connections)

Uploading it here will look like this:

blueprint.json (12.3 KB)

Following these steps will allow others to assist you here. Thanks!

2 Likes

Hello @samliew,
thanks for your reply. The scenario is very simple because I don’t put in this time all the logic that I want to achieve. I think “Before I figure out about the connection to the Gmail Api and after I construct all the scenario and the logic for changing the signature”.
Anyway you find the sceenshot attached to this message such as the blueprint.json

Can you help me with this issue?

Thanks

Gianluca


blueprint.json (13.6 KB)

This question was asked a couple of days ago, could you refer to this for additional information?

The endpoint is users.settings.sendAs.get and the scope is https://www.googleapis.com/auth/gmail.modify

and the Google OAuth instructions are as follows:

1a. Enable the relevant API

Direct Link: Google Cloud console

1b. Add the relevant scopes

Direct Link: https://console.cloud.google.com/apis/credentials/consent/edit

2. Insert all the known Google Redirect URIs for your app

Direct Link: https://console.cloud.google.com/apis/credentials

How to create an OAuth app in GCP: https://www.make.com/en/help/tutorials/calling-google-apis-via-the--http-make-a-oauth-2-0-request--module ← FOLLOW THIS

Here are all the known redirect URIs you need for your Google Cloud Console OAuth app. If you set these up, you can reuse the same GCP app for other Google apps and modules on Make.

https://www.make.com/oauth/cb/oauth2
https://www.make.com/oauth/cb/google-custom
https://www.make.com/oauth/cb/google-restricted
https://www.make.com/oauth/cb/google-cloud-speech
https://www.make.com/oauth/cb/google-analytics-4
https://www.integromat.com/oauth/cb/oauth2
https://www.integromat.com/oauth/cb/google-custom
https://www.integromat.com/oauth/cb/google-restricted
https://www.integromat.com/oauth/cb/google-cloud-speech
https://www.integromat.com/oauth/cb/google-analytics-4

Once you’ve set these up, you can use/reuse the same Make connection for all the supported Google apps & modules on Make - you’ll only have to enable the respective APIs for your custom app in Google Cloud.

3. Publish your GCP OAuth2 app

Direct Link: https://console.cloud.google.com/apis/credentials/consent

You might need to set your OAuth application to “Production”, otherwise the credentials expire very frequently.

1. To do this, go to menu item “OAuth consent screen”

or click here https://console.cloud.google.com/apis/credentials/consent

2. Then click the button below if the Publishing status is not “In production”

4. Configure the HTTP OAuth2 module

You need a “Authorize parameters” key of redirect_uri with the above Make OAuth2 callback URL.

You can find the Client ID and Client Secret in the OAuth2 app you created in GCP, on the right-hand side of where you inserted the 8 callback URLs in step 2:

2 Likes

Connection settings

Module settings

Output

2 Likes

Since the response variable sendAs is an array,

It is likely the first item in the array is the primary/default signature (HTML format).

Screenshot_2024-04-08_220426

You can use the functions map and first to get the signature.

E.g.:

{{first(map(1.data.sendAs; "signature"; "isDefault"; "true"))}}

2 Likes

Hello @samliew,
thanks for your kindly reply. Firstly I want to change the signature (also for alias) and not get it, but also get it could be useful…so anyway thanks.
I try to figure it out and I think that I setup everything correct. Attached hereto some screenshot
Scopes:



As you can see the modify API is selected

Credentials


The app is in production

+Make connection*



Even if I don’t understand why you put as scope https://www.googleapis.com/auth/indexing

Make module
Shared with Zight

If I run the module it gives me this error:
Shared with Zight

It’s about 2 hours that I’m stuck in this point can you help me? Also consider that I want to CHANGE the signature for each alias
Thanks so much

Hello @samliew ,
sorry if I bother you again, but I’m quite stuck and I want to ask if you have time to see and tell me what I missing out

Thanks

As a workspace administrator, you could try using existing tools to manage your organization.

Here is a free tool for Google Admins that allows you to update user signatures on the organization, OU, group, or individual level: Signature Manager for Gmail

As for the connection set-up in Make, you need to sign in with the main Google Workspace service account and not one of the sub-accounts, otherwise you can only amend your own signature.

3 Likes

Hello @samliew,
thanks for your reply. I can’t use the external tools you suggested because some features that I need is missing. For example (but there are more) I have to update the signature for each sendas email for each users, also the text inside signature comes from a complex scenario inside Make. So call the correct API and make it working is crucial in my case.

Anyway follow this link and this link and your previous answers I figure out how to use API for my user…so THANK YOU :grinning:

Please note that one of the two linked guide has screen and information expired and it could be a great thing to update it with latest screen and data (such as the redirect urls)

Now I’m in a little (very little) step to solve my issue. In the latest post you are right:

As for the connection set-up in Make, you need to sign in with the main Google Workspace service account and not one of the sub-accounts.

So I create a serivce account inside app and grant it access to all the Workspace domain. I put it as propertary and I give to it the right scope. When I try to use in the connection (taking the right client id and password) I have this error back (I translate from Italian so some words could be different but the sense should remain the same):

You can’t access to this app because it’s not compliance with Google OAuth 2.0.

If you develop this app, register the redirect URI in the Goggle Cloud Console.
Details: redirect_uri=https://www.integromat.com/oauth/cb/oauth2

Thinking of it there is no place where I create or editing the service account where I can put the alla authorized redirect so it could be for this reason that it doesn’t work. Or perhaps something other…can you help me to make this little step forward?

Thanks so much

Gianluca

See step 2 below:

1. Enable the API

Direct Link: Google Cloud console

2. Insert all the known Google Redirect URIs for your app

Direct Link: https://console.cloud.google.com/apis/credentials

How to create an OAuth app in GCP: https://www.make.com/en/help/tutorials/calling-google-apis-via-the--http-make-a-oauth-2-0-request--module ← FOLLOW THIS

Here are all the known redirect URIs you need for your Google Cloud Console OAuth app. If you set these up, you can reuse the same GCP app for other Google apps and modules on Make.

https://www.make.com/oauth/cb/oauth2
https://www.make.com/oauth/cb/google-custom
https://www.make.com/oauth/cb/google-restricted
https://www.make.com/oauth/cb/google-cloud-speech
https://www.make.com/oauth/cb/google-analytics-4
https://www.integromat.com/oauth/cb/oauth2
https://www.integromat.com/oauth/cb/google-custom
https://www.integromat.com/oauth/cb/google-restricted
https://www.integromat.com/oauth/cb/google-cloud-speech
https://www.integromat.com/oauth/cb/google-analytics-4

Once you’ve set these up, you can use/reuse the same Make connection for all the supported Google apps & modules on Make - you’ll only have to enable the respective APIs for your custom app in Google Cloud.

3. Publish your GCP OAuth2 app

Direct Link: https://console.cloud.google.com/apis/credentials/consent

You might need to set your OAuth application to “Production”, otherwise the credentials expire very frequently.

1. To do this, go to menu item “OAuth consent screen”

or click here https://console.cloud.google.com/apis/credentials/consent

2. Then click the button below if the Publishing status is not “In production”

4. Configure the HTTP OAuth2 module

You need a “Authorize parameters” key of redirect_uri with the above Make OAuth2 callback URL.

You can find the Client ID and Client Secret in the OAuth2 app you created in GCP, on the right-hand side of where you inserted the 8 callback URLs in step 2:

1 Like

Hello @samliew
thanks for your reply. Unfortunately something doesn’t work. In your answer you assume that I use a user account and not a service account as I do.
The problem is when I setup a service account and the fact I don’t have a space where to put the Authrorized redirect URIs

Can you help me?

2 Likes