access delegated mail folder with gmail api

2019-03-06 16:52发布

问题:

let's say there are alice@gmail.com and bob@gmail.com. Alice has delegated her account to Bob. When I authenticate with Bob and try to list Alice inbox using the REST interface I get a 403 error:

bob@gmail.com does not have privileges to alice@gmail.com mailbox.

The URL used to query the inbox is:

www.googleapis.com/gmail/v1/users/alice@gmail.com/messages

When I use bob@gmail.com (or me) as userId there is no problem. How do I access Alice's account?

Greetings

回答1:

You would need to get alice's consent and oauth token to access alice's account through the API--delegation is not supported like it is in the web interface.