Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions packages/google-auth/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,6 @@ Supported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^
Python >= 3.10

Unsupported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Python == 2.7: The last version of this library with support for Python 2.7
was `google.auth == 1.34.0`.

- Python 3.5: The last version of this library with support for Python 3.5
was `google.auth == 1.23.0`.

- Python 3.6: The last version of this library with support for Python 3.6
was `google.auth == 2.22.0`.

- Python 3.7: The last version of this library with support for Python 3.7
was `google.auth == 2.45.0`.


Documentation
Expand Down
22 changes: 11 additions & 11 deletions packages/google-auth/google/auth/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,23 @@ def python_and_auth_lib_version():


# x-goog-api-client header value for access token request via metadata server.
# Example: "gl-python/3.7 auth/1.1 auth-request-type/at cred-type/mds"
# Example: "gl-python/<python-version> auth/<library-version> auth-request-type/at cred-type/mds"
def token_request_access_token_mds():
return "{} {} {}".format(
python_and_auth_lib_version(), REQUEST_TYPE_ACCESS_TOKEN, CRED_TYPE_SA_MDS
)


# x-goog-api-client header value for ID token request via metadata server.
# Example: "gl-python/3.7 auth/1.1 auth-request-type/it cred-type/mds"
# Example: "gl-python/<python-version> auth/<library-version> auth-request-type/it cred-type/mds"
def token_request_id_token_mds():
return "{} {} {}".format(
python_and_auth_lib_version(), REQUEST_TYPE_ID_TOKEN, CRED_TYPE_SA_MDS
)


# x-goog-api-client header value for impersonated credentials access token request.
# Example: "gl-python/3.7 auth/1.1 auth-request-type/at cred-type/imp"
# Example: "gl-python/<python-version> auth/<library-version> auth-request-type/at cred-type/imp"
def token_request_access_token_impersonate():
return "{} {} {}".format(
python_and_auth_lib_version(),
Expand All @@ -76,7 +76,7 @@ def token_request_access_token_impersonate():


# x-goog-api-client header value for impersonated credentials ID token request.
# Example: "gl-python/3.7 auth/1.1 auth-request-type/it cred-type/imp"
# Example: "gl-python/<python-version> auth/<library-version> auth-request-type/it cred-type/imp"
def token_request_id_token_impersonate():
return "{} {} {}".format(
python_and_auth_lib_version(), REQUEST_TYPE_ID_TOKEN, CRED_TYPE_SA_IMPERSONATE
Expand All @@ -85,7 +85,7 @@ def token_request_id_token_impersonate():

# x-goog-api-client header value for service account credentials access token
# request (assertion flow).
# Example: "gl-python/3.7 auth/1.1 auth-request-type/at cred-type/sa"
# Example: "gl-python/<python-version> auth/<library-version> auth-request-type/at cred-type/sa"
def token_request_access_token_sa_assertion():
return "{} {} {}".format(
python_and_auth_lib_version(), REQUEST_TYPE_ACCESS_TOKEN, CRED_TYPE_SA_ASSERTION
Expand All @@ -94,15 +94,15 @@ def token_request_access_token_sa_assertion():

# x-goog-api-client header value for service account credentials ID token
# request (assertion flow).
# Example: "gl-python/3.7 auth/1.1 auth-request-type/it cred-type/sa"
# Example: "gl-python/<python-version> auth/<library-version> auth-request-type/it cred-type/sa"
def token_request_id_token_sa_assertion():
return "{} {} {}".format(
python_and_auth_lib_version(), REQUEST_TYPE_ID_TOKEN, CRED_TYPE_SA_ASSERTION
)


# x-goog-api-client header value for user credentials token request.
# Example: "gl-python/3.7 auth/1.1 cred-type/u"
# Example: "gl-python/<python-version> auth/<library-version> cred-type/u"
def token_request_user():
return "{} {}".format(python_and_auth_lib_version(), CRED_TYPE_USER)

Expand All @@ -111,25 +111,25 @@ def token_request_user():


# x-goog-api-client header value for metadata server ping.
# Example: "gl-python/3.7 auth/1.1 auth-request-type/mds"
# Example: "gl-python/<python-version> auth/<library-version> auth-request-type/mds"
def mds_ping():
return "{} {}".format(python_and_auth_lib_version(), REQUEST_TYPE_MDS_PING)


# x-goog-api-client header value for reauth start endpoint calls.
# Example: "gl-python/3.7 auth/1.1 auth-request-type/re-start"
# Example: "gl-python/<python-version> auth/<library-version> auth-request-type/re-start"
def reauth_start():
return "{} {}".format(python_and_auth_lib_version(), REQUEST_TYPE_REAUTH_START)


# x-goog-api-client header value for reauth continue endpoint calls.
# Example: "gl-python/3.7 auth/1.1 cred-type/re-cont"
# Example: "gl-python/<python-version> auth/<library-version> cred-type/re-cont"
Comment thread
chalmerlowe marked this conversation as resolved.
def reauth_continue():
return "{} {}".format(python_and_auth_lib_version(), REQUEST_TYPE_REAUTH_CONTINUE)


# x-goog-api-client header value for BYOID calls to the Security Token Service exchange token endpoint.
# Example: "gl-python/3.7 auth/1.1 google-byoid-sdk source/aws sa-impersonation/true sa-impersonation/true"
# Example: "gl-python/<python-version> auth/<library-version> google-byoid-sdk source/aws sa-impersonation/true sa-impersonation/true"
Comment thread
chalmerlowe marked this conversation as resolved.
def byoid_metrics_header(metrics_options):
header = "{} {}".format(python_and_auth_lib_version(), BYOID_HEADER_SECTION)
for key, value in metrics_options.items():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ class Request(transport.Request):
"""

def __init__(self, session=None):
# TODO: Use auto_decompress property for aiohttp 3.7+
if session is not None and session._auto_decompress:
if session is not None and getattr(session, "auto_decompress", None) is True:
raise exceptions.InvalidOperation(
"Client sessions with auto_decompress=True are not supported."
)
Expand Down
2 changes: 1 addition & 1 deletion packages/google-auth/google/oauth2/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def __init__(
def __getstate__(self):
"""A __getstate__ method must exist for the __setstate__ to be called
This is identical to the default implementation.
See https://docs.python.org/3.7/library/pickle.html#object.__setstate__
See https://docs.python.org/3/library/pickle.html#object.__setstate__
"""
state_dict = self.__dict__.copy()
# Remove _refresh_handler function as there are limitations pickling and
Expand Down
6 changes: 3 additions & 3 deletions packages/google-auth/tests/compute_engine/test__metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@
b"-----END CERTIFICATE-----\n"
)

ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE = (
"gl-python/3.7 auth/1.1 auth-request-type/at cred-type/mds"
ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE = "gl-python/<python-version> auth/<library-version> auth-request-type/at cred-type/mds"
MDS_PING_METRICS_HEADER_VALUE = (
"gl-python/<python-version> auth/<library-version> auth-request-type/mds"
)
MDS_PING_METRICS_HEADER_VALUE = "gl-python/3.7 auth/1.1 auth-request-type/mds"
MDS_PING_REQUEST_HEADER = {
"metadata-flavor": "Google",
"x-goog-api-client": MDS_PING_METRICS_HEADER_VALUE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@
b"bsxbLa6Fp0SYeYwO8ifEnkRvasVpc1WTQqfRB2JCj5pTBDzJpIpFCMmnQ"
)

ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE = (
"gl-python/3.7 auth/1.1 auth-request-type/at cred-type/mds"
)
ID_TOKEN_REQUEST_METRICS_HEADER_VALUE = (
"gl-python/3.7 auth/1.1 auth-request-type/it cred-type/mds"
)
ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE = "gl-python/<python-version> auth/<library-version> auth-request-type/at cred-type/mds"
ID_TOKEN_REQUEST_METRICS_HEADER_VALUE = "gl-python/<python-version> auth/<library-version> auth-request-type/it cred-type/mds"
FAKE_SERVICE_ACCOUNT_EMAIL = "foo@bar.com"
FAKE_QUOTA_PROJECT_ID = "fake-quota-project"
FAKE_SCOPES = ["scope1", "scope2"]
Expand Down
8 changes: 2 additions & 6 deletions packages/google-auth/tests/oauth2/test__client.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,8 @@
" https://www.googleapis.com/auth/logging.write"
)

ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE = (
"gl-python/3.7 auth/1.1 auth-request-type/at cred-type/sa"
)
ID_TOKEN_REQUEST_METRICS_HEADER_VALUE = (
"gl-python/3.7 auth/1.1 auth-request-type/it cred-type/sa"
)
ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE = "gl-python/<python-version> auth/<library-version> auth-request-type/at cred-type/sa"
ID_TOKEN_REQUEST_METRICS_HEADER_VALUE = "gl-python/<python-version> auth/<library-version> auth-request-type/it cred-type/sa"


@pytest.mark.parametrize("retryable", [True, False])
Expand Down
10 changes: 7 additions & 3 deletions packages/google-auth/tests/oauth2/test_reauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@
"encodedProofOfReauthToken": "new_rapt_token",
}

REAUTH_START_METRICS_HEADER_VALUE = "gl-python/3.7 auth/1.1 auth-request-type/re-start"
REAUTH_START_METRICS_HEADER_VALUE = (
"gl-python/<python-version> auth/<library-version> auth-request-type/re-start"
)
REAUTH_CONTINUE_METRICS_HEADER_VALUE = (
"gl-python/3.7 auth/1.1 auth-request-type/re-cont"
"gl-python/<python-version> auth/<library-version> auth-request-type/re-cont"
)
TOKEN_REQUEST_METRICS_HEADER_VALUE = (
"gl-python/<python-version> auth/<library-version> cred-type/u"
)
TOKEN_REQUEST_METRICS_HEADER_VALUE = "gl-python/3.7 auth/1.1 cred-type/u"


class MockChallenge(object):
Expand Down
10 changes: 7 additions & 3 deletions packages/google-auth/tests/test__default.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import json
import os
import sys
from unittest import mock
import warnings

Expand Down Expand Up @@ -773,7 +774,9 @@ def test__get_gae_credentials_gen1(app_identity):

@mock.patch.dict(os.environ)
def test__get_gae_credentials_gen2():
os.environ["GAE_RUNTIME"] = "python37"
os.environ[
"GAE_RUNTIME"
] = f"python{sys.version_info.major}{sys.version_info.minor}"
credentials, project_id = _default._get_gae_credentials()
assert credentials is None
assert project_id is None
Expand All @@ -783,8 +786,9 @@ def test__get_gae_credentials_gen2():
def test__get_gae_credentials_gen2_backwards_compat():
# compat helpers may copy GAE_RUNTIME to APPENGINE_RUNTIME
# for backwards compatibility with code that relies on it
os.environ[environment_vars.LEGACY_APPENGINE_RUNTIME] = "python37"
os.environ["GAE_RUNTIME"] = "python37"
current_runtime = f"python{sys.version_info.major}{sys.version_info.minor}"
os.environ[environment_vars.LEGACY_APPENGINE_RUNTIME] = current_runtime
os.environ["GAE_RUNTIME"] = current_runtime
credentials, project_id = _default._get_gae_credentials()
assert credentials is None
assert project_id is None
Expand Down
18 changes: 8 additions & 10 deletions packages/google-auth/tests/test_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@
from google.auth import transport
from google.auth.credentials import DEFAULT_UNIVERSE_DOMAIN

IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE = (
"gl-python/3.7 auth/1.1 auth-request-type/at cred-type/imp"
)
IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE = "gl-python/<python-version> auth/<library-version> auth-request-type/at cred-type/imp"

LANG_LIBRARY_METRICS_HEADER_VALUE = "gl-python/3.7 auth/1.1"
LANG_LIBRARY_METRICS_HEADER_VALUE = "gl-python/<python-version> auth/<library-version>"

CLIENT_ID = "username"
CLIENT_SECRET = "password"
Expand Down Expand Up @@ -1913,7 +1911,7 @@ def test_refresh_success_without_impersonation_ignore_default_scopes(
token_headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic " + BASIC_AUTH_ENCODING,
"x-goog-api-client": "gl-python/3.7 auth/1.1 google-byoid-sdk sa-impersonation/false config-lifetime/false source/aws",
"x-goog-api-client": "gl-python/<python-version> auth/<library-version> google-byoid-sdk sa-impersonation/false config-lifetime/false source/aws",
}
token_request_data = {
"grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
Expand Down Expand Up @@ -1972,7 +1970,7 @@ def test_refresh_success_without_impersonation_use_default_scopes(
token_headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic " + BASIC_AUTH_ENCODING,
"x-goog-api-client": "gl-python/3.7 auth/1.1 google-byoid-sdk sa-impersonation/false config-lifetime/false source/aws",
"x-goog-api-client": "gl-python/<python-version> auth/<library-version> google-byoid-sdk sa-impersonation/false config-lifetime/false source/aws",
}
token_request_data = {
"grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
Expand Down Expand Up @@ -2038,7 +2036,7 @@ def test_refresh_success_with_impersonation_ignore_default_scopes(
token_headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic " + BASIC_AUTH_ENCODING,
"x-goog-api-client": "gl-python/3.7 auth/1.1 google-byoid-sdk sa-impersonation/true config-lifetime/false source/aws",
"x-goog-api-client": "gl-python/<python-version> auth/<library-version> google-byoid-sdk sa-impersonation/true config-lifetime/false source/aws",
}
token_request_data = {
"grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
Expand Down Expand Up @@ -2133,7 +2131,7 @@ def test_refresh_success_with_impersonation_use_default_scopes(
token_headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic " + BASIC_AUTH_ENCODING,
"x-goog-api-client": "gl-python/3.7 auth/1.1 google-byoid-sdk sa-impersonation/true config-lifetime/false source/aws",
"x-goog-api-client": "gl-python/<python-version> auth/<library-version> google-byoid-sdk sa-impersonation/true config-lifetime/false source/aws",
}
token_request_data = {
"grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
Expand Down Expand Up @@ -2328,7 +2326,7 @@ def test_refresh_success_with_supplier_with_impersonation(
token_headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic " + BASIC_AUTH_ENCODING,
"x-goog-api-client": "gl-python/3.7 auth/1.1 google-byoid-sdk sa-impersonation/true config-lifetime/false source/programmatic",
"x-goog-api-client": "gl-python/<python-version> auth/<library-version> google-byoid-sdk sa-impersonation/true config-lifetime/false source/programmatic",
}
token_request_data = {
"grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
Expand Down Expand Up @@ -2414,7 +2412,7 @@ def test_refresh_success_with_supplier(self, utcnow, mock_auth_lib_value):
token_headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic " + BASIC_AUTH_ENCODING,
"x-goog-api-client": "gl-python/3.7 auth/1.1 google-byoid-sdk sa-impersonation/false config-lifetime/false source/programmatic",
"x-goog-api-client": "gl-python/<python-version> auth/<library-version> google-byoid-sdk sa-impersonation/false config-lifetime/false source/programmatic",
}
token_request_data = {
"grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
Expand Down
Loading
Loading