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

fix: preventing accessing predefined discovery URLs when override is provided #1324

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 7 additions & 8 deletions googleapiclient/discovery.py
Expand Up @@ -274,9 +274,6 @@ def build(
else:
static_discovery = False

if discoveryServiceUrl is None:
discoveryServiceUrl = DISCOVERY_URI

if http is None:
discovery_http = build_http()
else:
Expand Down Expand Up @@ -343,14 +340,16 @@ def _discovery_service_uri_options(discoveryServiceUrl, version):
A list of URIs to be tried for the Service Discovery, in order.
"""

urls = [discoveryServiceUrl, V2_DISCOVERY_URI]
# V1 Discovery won't work if the requested version is None
if discoveryServiceUrl == V1_DISCOVERY_URI and version is None:
if discoveryServiceUrl is not None:
return [discoveryServiceUrl]
if version is None:
# V1 Discovery won't work if the requested version is None
logger.warning(
"Discovery V1 does not support empty versions. Defaulting to V2..."
)
urls.pop(0)
return list(OrderedDict.fromkeys(urls))
return [V2_DISCOVERY_URI]
else:
return [DISCOVERY_URI, V2_DISCOVERY_URI]


def _retrieve_discovery_doc(
Expand Down