Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

403 when retreiving 'https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest' #959

Closed
thehesiod opened this issue Jul 6, 2020 · 9 comments
Assignees

Comments

@thehesiod
Copy link
Contributor

This has been logged on stack overflow: https://stackoverflow.com/questions/62761519/httperror-403-when-requesting-https-www-googleapis-com-discovery-v1-apis-gmail

and google support: https://issuetracker.google.com/issues/160441983

Environment details

  • OS type and version:
  • Python version: 3.8.2
  • pip version: 20.0.2
  • google-api-python-client version: 1.7.11

Steps to reproduce

  1. attempt to use gmail API

Code example

>>> from googleapiclient.discovery import build
>>> service = build('gmail', 'v1')

Stack trace

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/alex/.local/share/virtualenvs/virtualenv-6CTQ7t3F/lib/python3.8/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/Users/alex/.local/share/virtualenvs/virtualenv-6CTQ7t3F/lib/python3.8/site-packages/googleapiclient/discovery.py", line 244, in build
    raise e
  File "/Users/alex/.local/share/virtualenvs/virtualenv-6CTQ7t3F/lib/python3.8/site-packages/googleapiclient/discovery.py", line 228, in build
    content = _retrieve_discovery_doc(
  File "/Users/alex/.local/share/virtualenvs/virtualenv-6CTQ7t3F/lib/python3.8/site-packages/googleapiclient/discovery.py", line 291, in _retrieve_discovery_doc
    raise HttpError(resp, content, uri=actual_url)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest returned "The caller does not have permission">
@natefduncan
Copy link

I'm having this same issue.

@yonatanpc
Copy link

same issue for me.

@busunkim96
Copy link
Contributor

Hi all,

Sorry to hear you're having trouble. It looks like there is an issue with the backend API. The Gmail API team is actively working on a fix. Please keep an eye on https://issuetracker.google.com/issues/160441983.

I am closing this issue as there is no action we can take in the library.

@randalpinto
Copy link

This issue seems to only affect the Python library as it doesn't seem to cache the discovery file. This is a workaround recommended by a user in the issue:

_As a temporary workaround, the discovery document is available at:

https://raw.githubusercontent.com/googleapis/google-api-go-client/master/gmail/v1/gmail-api.json (this is a GitHub repository owned by Google for the Golang Google API library)

The Python client library can use this file stored locally rather than trying to retrieve it from googleapis.com:

discovery_doc = json.load('gmail-api.json')
gmail_service = googleapiclient.discovery.build_from_document(discovery_doc)
more details at:

http://googleapis.github.io/google-api-python-client/docs/epy/googleapiclient.discovery-module.html#build_from_document

there should be similar methods for other language libraries._

Seems to work fine on Javascript and Go as they seem to have a cache. Can you not align Python with them?

@thehesiod
Copy link
Contributor Author

the discovery file is cacheable via a cache class, however there is a TTL so eventually will fail

@busunkim96
Copy link
Contributor

@randalpinto We're looking into publishing the package with a copy of the discovery doc that the library can fall back to. No definite plans yet though.

@congkhoa
Copy link

congkhoa commented Jul 7, 2020

It's problem from Google side, and they already fix it.

@randalpinto
Copy link

@busunkim96 although this has now been addressed by Google sounds like a good idea to still have fallback discovery docs in the library as with all the other libraries? Is there a separate issue to track this request?

@busunkim96
Copy link
Contributor

Opened #962 to track.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants