Gmail API

@psweb hi

I have to build an application that will be a custom mail client. To simplify the first version of the application, I decided to use the Gmail API so that I could get a quick and convenient way to manage mail messages in full.

I began to study the documentation and the forum, and came across a large number of topics on the Gmail API from you. It looks like you have already successfully passed this path with the Gmail API. Can you give a brief instruction on what needs to be done to start working with gmail?

I see it like this:

  1. Google account registration.
  2. Establishing server authorization according to this manual: https://docs.wappler.io/t/google-service-account-authorization-with-jwt/26491
  3. Creating server actions using authorization from step 2 and Gmail REST api (https://developers.google.com/gmail/api/reference/rest).

Am I sticking to the right plan?

Thank you in advance

1 Like

Seems right to me, recalling back the steps I went through, although mine was a personal project and I haven’t actually completed it, as I got busy with client work and still have not gone back to it.

1 Like

I spent a whole week struggling with the Gmail API, but without success.

My task:

  • create a mailbox with a custom domain;
  • connect to this mailbox via Gmail API using service account.

What I did:

  1. Created an account in Google Workspace (14 days free of charge) and verified the domain by receiving a work mailbox with a custom domain:

  2. Gave the account the rights of the owner: 2

  3. Created a project within the organization:

  4. Created a service account in the project:

  5. Added a key:

  6. Added Gmail API to the project:

  7. In Google Workspace, I added delegation of access to data in the domain:

  8. Created a JWT token in a Wappler with full access to gmail:

  9. Created OAuth2 provider:

  10. Created an API action with a request for a list of messages:

However, I always get an error:
11

I note that I can easily recreate this manual without any errors:

Also, I have already read all the guides from google a hundred times and done everything that was indicated in them.

@Teodor, @psweb, @patrick what could I have missed?

I would be very grateful for any help to the community.

1 Like

Solution found

The settings on the Google side were executed correctly. Therefore, the post above can be used as a guide if you have a similar task.

For correct operation, there was not enough additional configuration on the Wappler side. Since when using a service account to connect to the Gmail API, it is necessary for the service account to act on behalf of a specific user, you must specify this when setting up the JWT token. Therefore, in step 8, you must specify the gmail user on whose behalf you plan to make api calls in the Subject field. Like so:

As a result, everything works fine:

I’m not complaining, but sometimes there’s not enough information in the documentation to make it easy to figure everything out.

3 Likes

Hey! Could you build your site successfully? I want to use Gmail API (my company uses workspace) to send mails to my clients notifications and replace my Sendgrid subscription.
Google’s documentation seems quite difficult to implement with wappler, I cant find any simple REST solution to send basic mails.

1 Like