GMAIl API: how to get messages without any prompting for authorization?

31 Views Asked by At

https://developers.google.com/gmail/api/quickstart/java

there is guide that`s describes only the way to get messages with authorization prompt.

The first time you run the sample, it prompts you to authorize access: If you're not already signed in to your Google Account, sign in when prompted. If you're signed in to multiple accounts, select one account to use for authorization. Click Accept.

Can we call it without any prompt, just using some kind of a token and if yes, than how to do it? Goal: to run automated tests locally and remotely and check one specific gmail for letters.

1

There are 1 best solutions below

0
Linda Lawton - DaImTo On

If you want to access Gmail on behalf of users on your domain then you should look into using a service account instead.

You can delegate your script to that of a user on the domain and it will be able to impersonate them. This means you wont need any user prompt for authorization.

delegate_settings

they don't appear to have a java sample there you may have to look around. I can tell you it works i created something for a client once.