GAM-team / got-your-back

Got Your Back (GYB) is a command line tool for backing up your Gmail messages to your computer using Gmail's API over HTTPS.
https://github.com/GAM-team/got-your-back/wiki
Apache License 2.0
2.62k stars 207 forks source link

Would it be possible to create a readonly version, as to reduce the scopes needed? #464

Open DavyLandman opened 5 months ago

DavyLandman commented 5 months ago

My admin is being a bit iffy about granting write rights to the organization, just for an automated backup.

I was looking at the scopes and I noticed that https://www.googleapis.com/auth/gmail.readonly exists, would it be possible to make a version that only does read-only requests? or is that a large undertaking?

hudcap commented 4 months ago

When you set it up for the first time, I'm pretty sure it asks for exactly which scopes you want to authorize. Can't promise, because I set this up ages ago...

hudcap commented 4 months ago

Yup: https://github.com/GAM-team/got-your-back/blob/493ddf9d1cc0229577f043c36c267a87e1e84f37/gyb.py#L470-L489

DavyLandman commented 4 months ago

aah, my bad, I should have used the force and read the source.

DavyLandman commented 4 months ago

@hudcap

I now remember, I was reading the wiki and here is says:

For API Scopes, enter exactly: https://mail.google.com/,https://www.googleapis.com/auth/apps.groups.migration,https://www.googleapis.com/auth/drive.appdata

So that what got me on the wrong foot. I'll see if it indeed also works for service accounts to be on .readonly scope.

Update: yup, just tried, the service account requires all those scopes, not possible with just the readonly scope.