EMDIS-ECS
view release on metacpan or search on metacpan
script/ecs_token view on Meta::CPAN
Location of C<gpgconf> program.
=item GPG_PRESET_PASSPHRASE
Location of C<gpg-preset-passphrase> program.
=item PASS_GPG_KEYGRIP
Keygrip identifying the GnuPG key used by C<pass>.
=item PASS_GPG_PASSPHRASE
Passphrase for the GnuPG key used by C<pass>.
=back
=head2 Gmail Setup Notes
The following are notes on setting up an app and getting an OAuth 2.0 access
token for use with Gmail SMTP/IMAP/POP3.
=over
=item 1.
Download C<oauth2.py> from GitHub. See comments in script for additional
info.
https://github.com/google/gmail-oauth2-tools/blob/master/python/oauth2.py
=item 2.
In a web browser, log in to the Google account that will be using Gmail.
https://accounts.google.com
=item 3.
Define the OAuth 2.0 client id and client secret to be used by the Perl ECS
app.
=over
=item 1.
Go to Google developers console.
https://console.developers.google.com
=item 2.
If needed, create a project. In I<Google Cloud> console, select
I<Navigation menu> (three horizontal bars in upper left corner of page) >
I<IAM & Admin> > I<Create a Project>. On I<New Project> page, enter
I<Project name> and select I<Location>, then click I<Create> button.
=item 3.
Select the applicable project. In I<Google Cloud> console, click the
I<Open project picker> button (next to Google Cloud logo at top of page),
then, in the I<Select a project> popup, click the link for the project.
=item 4.
Configure OAuth settings for the new project. In I<Google Cloud>
console, select I<Navigation menu> > I<APIs & Services> >
I<OAuth consent screen>. On the I<OAuth Overview> page, click the
I<Get started> button. On the I<Project configuration> page, under
I<App Information> enter the I<App name> and I<User support email>, and
click the I<Next> button. Under I<Audience> select I<External> and click
the I<Next> button. Under I<Contact information> enter I<Email addresses>
and click the I<Next> button. Under I<Finish> click the I<I agree ...>
checkbox and click the I<Continue> button. Then, click the I<Create>
button.
=item 5.
Create OAuth 2.0 client ID for Perl ECS app. In I<Google Cloud> console,
select I<Navigation menu> > I<APIs & Services> > I<Credentials>. On the
I<Credentials> page, click the I<+ Create credentials> button and select
I<OAuth client ID> from the drop-down menu. On the I<Create OAuth client ID>
page select I<Web application> as the I<Application type> and enter an
appropriate name for the app (e.g. "Perl ECS"). Under
I<Authorized redirect URIs> click the I<+ Add URI> button and enter the
following URI (as mentioned in the C<oauth.py> script):
https://google.github.io/gmail-oauth2-tools/html/oauth2.dance.html
Then, click the I<Create> button.
From the I<OAuth client created> popup, make note of the I<Client ID> and
I<Client secret>. Click I<OK>.
=item 6.
Allow a few minutes for the settings to take effect.
=back
=item 4.
Add the email account as a test user for the project. In I<Google Cloud>
console, select I<Navigation menu> > I<APIs & Services> >
I<OAuth consent screen>, then select I<Audience>. On the I<Audience>
page, under I<Test users> click the I<+ Add users> button. In the
I<Add users> panel enter the test user's email address (e.g. xyz@gmail.com)
and click the I<Save> button.
=item 5.
Use C<oauth2.py> script to generate and authorize an OAuth 2 token. See also
comments in script. E.g.:
python3 oauth2.py --user=xyz@gmail.com \
--client_id=1038[...].apps.googleusercontent.com \
--client_secret=VWFn8LIKAMC-MsjBMhJeOplZ \
--generate_oauth2_token
To authorize the token, use a web browser to visit the URL indicated by the
script and follow the browser-based authorization flow. At the script's
C<Enter verification code> prompt, enter the authorization code displayed in
the web browser. If successful, the script displays a C<Refresh Token> and
C<Access Token>.
If the browser authorization flow results in an error saying "Access
blocked: google.github.io has not completed the Google verification process",
add the email account as a test user for the project (see above) and reload
the URL provided by the C<oauth2.py> script.
=item 6.
Use C<oauth2.py> script to test SMTP authentication. E.g.:
python3 oauth2.py --user=xxx@gmail.com \
--access_token=ya29.a0A[...]0175 \
--test_smtp_authentication
=item 7.
Use C<oauth2.py> script to test IMAP authentication. E.g.:
python3 oauth2.py --user=xxx@gmail.com \
--access_token=ya29.a0A[...]0175 \
--test_imap_authentication
=item 8.
Use C<oauth2.py> script to obtain a new access token, using a refresh token.
E.g.:
python3 oauth2.py \
( run in 0.947 second using v1.01-cache-2.11-cpan-364913b4093 )