Skip to content

Gmail API "Delegation denied" #88

@alown

Description

@alown

Hi,

I am using commit b35f0e3.
After following the instructions in the readme, using the default api credentials, and performing a gmi init my-account@gmail.com. Having succesfully followed the oauth flow to generate some valid credentials. I then found myself unable to then perform a gmi pull, instead getting the below 403.

Traceback (most recent call last):
  File "/home/ali/projects/src/gmailieer/gmi", line 8, in <module>
    g.main ()
  File "/scratch/projects/src/gmailieer/lieer/gmailieer.py", line 149, in main
    args.func (args)
  File "/scratch/projects/src/gmailieer/lieer/gmailieer.py", line 320, in pull
    self.remote.get_labels () # to make sure label map is initialized
  File "/scratch/projects/src/gmailieer/lieer/remote.py", line 110, in func_wrap
    return func (self, *args, **kwargs)
  File "/scratch/projects/src/gmailieer/lieer/remote.py", line 139, in get_labels
    results = self.service.users ().labels ().list (userId = self.account).execute ()
  File "/scratch/projects/src/gmailieer-venv/lib/python3.5/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/scratch/projects/src/gmailieer-venv/lib/python3.5/site-packages/googleapiclient/http.py", line 842, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/gmail/v1/users/my-account%40gmail.com/labels?alt=json returned "Delegation denied for my-account@googlemail.com">

Some searching around suggested the use of the magic user id "me" instead, to force the api to refer to the default account referenced by the oauth credentials.

Manually editing the .gmailieer.json file to have "account":"me" instead of "account":"my-account@gmail.com", did indeed resolve the above error - though I don't fully understand why.

As I couldn't find mention of this in the readme/wiki/existing issues, I thought you may be interested to know, in case this can be automatically detected/performed/worked-around?

Thanks

P.S. Here are some more stats from a test account, in case you wish to add another data-point to the wiki

pull: full synchronization (no previous synchronization state)
fetching messages: 2357it [00:03, 726.70it/s]    
receiving content: 100%|█| 2357/2357 [02:34<00:00, 15.26it/s]
receiving metadata: everything up-to-date.
current historyId: 486955, current revision: 7078

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions