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

Gmail API example #44

Open
phlbnks opened this issue Jan 31, 2023 · 1 comment
Open

Gmail API example #44

phlbnks opened this issue Jan 31, 2023 · 1 comment

Comments

@phlbnks
Copy link

phlbnks commented Jan 31, 2023

Can anyone share a working Gmail API example? Everything was working fine with local files, but I want to move to reading over the API instead.

I've currently:

  • created an application in Google Console, enabled Gmail API, downloaded OAuth Client ID json for desktop application
  • updated docker-compose.yml to show more command: parsedmarc -c /parsedmarc.ini /input/* --verbose --debug
  • added COPY oauth.json / to parsedmarc/Dockerfile
  • updated parsedmarc/parsedmarc.ini with:
[gmail_api]
credentials_file = /oauth.json
include_spam_trash = False

But when parsedmark boots it just hangs, apparently waiting. I presume it's waiting for a user driven authentication process, but I can't work out how to access that??? What am I missing! I also tried using a service account json file but that failed too.

Problems I see / guestimate:

  • how to interact with parsedmarc / oauth flow
  • parsedmarc code specifically doesn't launch a browser for oauth as far as I can see so not sure how that works
  • specifying user / account with oauth or service account if not using a browser flow

If anyone has this working I'd appreciate a nudge in the right direction!

@phlbnks
Copy link
Author

phlbnks commented Jan 31, 2023

I think I have this sorted. I'm not sure what the "correct" way to handle it is, but feeding parsedmarc a token file from oauth flow completed using a bash script / curl works:

  • Save OAuth credentials as parsedmarc/credentials.json
  • In parsedmarc/Dockerfile COPY oauth.token /
  • In parsedmarc/parsedmarc.ini: token_file = /oauth.token
  • Then generate parsedmarc/oauth.token by running gmail_oauth.sh

Leaving this open for now in case of input on canonical solution

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

1 participant