Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: gmail_api Stuck on Authentication #545

Open
superstes opened this issue Aug 28, 2024 · 2 comments
Open

Problem: gmail_api Stuck on Authentication #545

superstes opened this issue Aug 28, 2024 · 2 comments

Comments

@superstes
Copy link

It seems the gmail api is stuck at creating the oauth token.
Here it calls the external flow module: https://github.com/domainaware/parsedmarc/blob/master/parsedmarc/mail/gmail.py#L30
This flow module states:

The server strategy instructs the user to open the authorization URL in
their browser and will attempt to automatically open the URL for them.

So basically it waits (forever) for you to open the browser and log-in interactively (from what I understand).

I had success using a service account for the non-interactive API access.
But for this to work, the _get_creds function needs to be rewritten to this:

from google.oauth2 import service_account

def _get_creds(credentials_file, scopes):
    return service_account.Credentials.from_service_account_file(
        credentials_file, scopes=scopes,
    ).with_subject('<YOUR-DMARC-ACCOUNT-EMAIL-ADDRESS>')

Note that the content of the credentials_file.json needs to replaced by the service account key

@superstes
Copy link
Author

Also: Have not found a streight-forward documentation on how to assign privileges to the service-account. Got stuck on unprivileged access and retracted to use imap with app-passwords.. https://support.google.com/accounts/answer/185833?hl=en

@seanthegeek
Copy link
Contributor

@nathanthorpe @mkupferman worked on the Gmail integration and can probably shed some light on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants