Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gmail OAuth from within docker container

I have various backend services running in containers. I am writing a microservice to handle the sending of emails.

My email provider for business emails is GSuite (Gmail).

I've been reading the following tutorial

This all seems well and good but it requires human intervention in order to authorise the application to send emails.

I need this to be fully autonomous in that whenever the container starts up it requests access tokens and authorises itself.

Is this possible? I can't seem to find any literature to help

like image 396
mwild Avatar asked Jul 31 '26 09:07

mwild


1 Answers

I found a solution to this and thought I would post it just in case anyone else stumbles across this problem.

The answer to accessing the GMAIL API with no human intervention is service accounts.

Service accounts can impersonate authenticated users. For instance, I now have a service account sending emails as if they are coming from [email protected]

I basically followed this.

There are a few other steps to setting up service accounts that can be found here.

I hope this helps someone.

like image 154
mwild Avatar answered Aug 02 '26 22:08

mwild



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!