Eliot Levitt
Eliot Levitt

Reputation: 45

Personal "Internal" Script against GMail API

This is driving me crazy.

I have a simple Python script to do some mail management against my personal GMail using the Google Mail API.

The only way I can seem to get it to work is to keep it in "Testing" status and refreshing the token every seven days.

On the API admin page, I try to make it internal, but I get this tooltip: "Because you're not a Google Workspace user..."

Except I am a Google Workspace user. I have the $8/monthly Google Workspace Individual subscription.

Surely people do the same thing I'm doing, writing little personal scripts against their personal email or personal calendar that are not intended to be public apps, and they manage to do them in some way that doesn't require putting it into test mode until the end of time, resetting the key every week.

(I considered getting a Business subscription—which would allow me to publish something "internal"—but not only is that just too expensive for this use case, I want this project to run against my personal account, not against some other business account.)

Can anyone tell me the secret I'm missing?

"Because you're not a Google Workspace user..."

Upvotes: 1

Views: 229

Answers (2)

Martin Zeitler
Martin Zeitler

Reputation: 76769

You need to refresh the access token when this happens ...since you've only posted a screenshot, that's all I can tell. However, when looking at the documentation, using a service-account (which can impersonate your user account) might be less effort, because these credentials will not expire, to begin with. Of course, one may say "using a service account for a single one user is overkill" - but the only alternative to that is implementing the token refresh (as one commonly does it for multiple external users). And with only 1 internal user, this requirement is completely voided.

Upvotes: 2

Fernando Lara
Fernando Lara

Reputation: 2426

Based on the message that you are getting, the problem seems related to the project being owned by a gmail.com account (you can check the ownership in IAM & Admin >> IAM).

Internal projects would only work for the domain you are working on. I remember you do have an option to whitelist other domains to have access to the resources and run it, but I am not sure if you can use it to whitelist the gmail.com domain.

If you want to leave it as internal, I would suggest changing the ownership of the project to the Google Workspace account and test using the option to whitelist domains.

Upvotes: 0

Related Questions