simplegmail icon indicating copy to clipboard operation
simplegmail copied to clipboard

Enables Using Environment Variable for Authorization - Issue #49

Open Tylerlhess opened this issue 1 year ago • 0 comments

Solves #49

Added an init option to the Gmail class to respect environment variable SIMPLEGMAIL_CREDENTIALS as an alternative to having the gmail_token.json.

Why:

This provides a solution for dockerizing a project using secrets. While you can mount a secret as a file within k8s and updating that file won't affect the pods operation this is not true with docker. This allows you to set the variable and the container build and manage the auth token file without reauthorization or having to give write permissions to each container sharing the same bind mount.

Use:

set the environment variable in the shell

export SIMPLEGMAIL_CREDENTIALS=$(cat gmail_token.json)  
# script.py
from simplegmail import Gmail

gmail = Gmail(use_envvars=True)

Tylerlhess avatar Apr 10 '24 18:04 Tylerlhess