dmarc-visualizer icon indicating copy to clipboard operation
dmarc-visualizer copied to clipboard

Gmail API example

Open phlbnks opened this issue 2 years ago • 1 comments

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 avatar Jan 31 '23 10:01 phlbnks

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

phlbnks avatar Jan 31 '23 23:01 phlbnks