google-auth 2.49.0__tar.gz → 3.0.0.dev0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {google_auth-2.49.0/google_auth.egg-info → google_auth-3.0.0.dev0}/PKG-INFO +14 -29
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/README.rst +7 -12
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/__init__.py +7 -11
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/_agent_identity_utils.py +9 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/_default.py +7 -18
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/_helpers.py +1 -22
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/aio/transport/aiohttp.py +8 -23
- google_auth-3.0.0.dev0/google/auth/aio/transport/sessions.py +268 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/app_engine.py +2 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/aws.py +2 -3
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/compute_engine/_metadata.py +14 -42
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/compute_engine/credentials.py +2 -2
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/credentials.py +3 -3
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/crypt/__init__.py +15 -18
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/crypt/_cryptography_rsa.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/crypt/es.py +2 -2
- google_auth-3.0.0.dev0/google/auth/crypt/rsa.py +20 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/environment_vars.py +0 -28
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/external_account.py +2 -2
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/external_account_authorized_user.py +9 -9
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/iam.py +19 -20
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/identity_pool.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/impersonated_credentials.py +3 -10
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/jwt.py +4 -3
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/pluggable.py +10 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/transport/_aiohttp_requests.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/transport/_mtls_helper.py +24 -52
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/transport/grpc.py +5 -5
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/transport/mtls.py +4 -17
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/transport/requests.py +2 -3
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/transport/urllib3.py +4 -3
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/version.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/oauth2/__init__.py +7 -11
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/oauth2/_client.py +2 -2
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/oauth2/_client_async.py +2 -2
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/oauth2/challenges.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/oauth2/credentials.py +2 -5
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/oauth2/id_token.py +7 -10
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/oauth2/service_account.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/oauth2/webauthn_handler.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0/google_auth.egg-info}/PKG-INFO +14 -29
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google_auth.egg-info/SOURCES.txt +2 -10
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google_auth.egg-info/requires.txt +5 -2
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google_auth.egg-info/top_level.txt +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/setup.cfg +3 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/setup.py +8 -11
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/compute_engine/test__metadata.py +5 -39
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/compute_engine/test__mtls.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/compute_engine/test_credentials.py +15 -23
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/conftest.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/oauth2/test__client.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/oauth2/test_challenges.py +2 -2
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/oauth2/test_credentials.py +1 -26
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/oauth2/test_gdch_credentials.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/oauth2/test_id_token.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/oauth2/test_reauth.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/oauth2/test_service_account.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/oauth2/test_sts.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/oauth2/test_webauthn_handler.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/oauth2/test_webauthn_handler_factory.py +1 -2
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/oauth2/test_webauthn_types.py +3 -3
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test__cloud_sdk.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test__default.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test__exponential_backoff.py +1 -2
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test__helpers.py +0 -47
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test__oauth2client.py +2 -2
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test__refresh_worker.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test_agent_identity_utils.py +18 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test_app_engine.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test_aws.py +9 -3
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test_credentials.py +2 -3
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test_downscoped.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test_external_account.py +3 -3
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test_external_account_authorized_user.py +7 -7
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test_iam.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test_identity_pool.py +3 -3
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test_impersonated_credentials.py +7 -31
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test_jwt.py +2 -2
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test_metrics.py +2 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test_pluggable.py +25 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/transport/aio/test_aiohttp.py +4 -5
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/transport/aio/test_sessions.py +1 -16
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/transport/test__custom_tls_signer.py +3 -7
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/transport/test__mtls_helper.py +15 -136
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/transport/test_grpc.py +1 -1
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/transport/test_mtls.py +16 -84
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/transport/test_requests.py +5 -5
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/transport/test_urllib3.py +4 -4
- google_auth-2.49.0/google/auth/_cache.py +0 -64
- google_auth-2.49.0/google/auth/aio/transport/mtls.py +0 -197
- google_auth-2.49.0/google/auth/aio/transport/sessions.py +0 -576
- google_auth-2.49.0/google/auth/crypt/_python_rsa.py +0 -199
- google_auth-2.49.0/google/auth/crypt/rsa.py +0 -127
- google_auth-2.49.0/tests/crypt/test__python_rsa.py +0 -203
- google_auth-2.49.0/tests/crypt/test_rsa.py +0 -175
- google_auth-2.49.0/tests/test__cache.py +0 -82
- google_auth-2.49.0/tests/test_version_warnings.py +0 -63
- google_auth-2.49.0/tests/transport/aio/test_sessions_mtls.py +0 -142
- google_auth-2.49.0/tests/transport/test_aio_mtls_helper.py +0 -202
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/LICENSE +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/MANIFEST.in +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/_cloud_sdk.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/_constants.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/_credentials_async.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/_credentials_base.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/_default_async.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/_exponential_backoff.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/_jwt_async.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/_oauth2client.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/_refresh_worker.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/_service_account_info.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/aio/__init__.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/aio/_helpers.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/aio/credentials.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/aio/transport/__init__.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/api_key.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/compute_engine/__init__.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/compute_engine/_mtls.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/crypt/_helpers.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/crypt/base.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/crypt/es256.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/downscoped.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/exceptions.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/metrics.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/py.typed +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/transport/__init__.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/transport/_custom_tls_signer.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/transport/_http_client.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/auth/transport/_requests_base.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/oauth2/_credentials_async.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/oauth2/_id_token_async.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/oauth2/_reauth_async.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/oauth2/_service_account_async.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/oauth2/gdch_credentials.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/oauth2/py.typed +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/oauth2/reauth.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/oauth2/sts.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/oauth2/utils.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/oauth2/webauthn_handler_factory.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google/oauth2/webauthn_types.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/google_auth.egg-info/dependency_links.txt +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/__init__.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/aio/test__helpers.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/compute_engine/__init__.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/compute_engine/data/smbios_product_name +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/compute_engine/data/smbios_product_name_non_google +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/crypt/__init__.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/crypt/test__cryptography_rsa.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/crypt/test_crypt.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/crypt/test_es.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/crypt/test_es256.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/authorized_user.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/authorized_user_cloud_sdk.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/authorized_user_cloud_sdk_with_quota_project_id.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/authorized_user_with_rapt_token.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/client_secrets.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/context_aware_metadata.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/enterprise_cert_invalid.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/enterprise_cert_valid.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/enterprise_cert_valid_provider.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/es256_privatekey.pem +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/es256_public_cert.pem +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/es256_publickey.pem +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/es256_service_account.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/es384_privatekey.pem +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/es384_public_cert.pem +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/es384_publickey.pem +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/es384_service_account.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/external_account_authorized_user.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/external_account_authorized_user_non_gdu.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/external_subject_token.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/external_subject_token.txt +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/gdch_service_account.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/impersonated_service_account_authorized_user_source.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/impersonated_service_account_external_account_authorized_user_source.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/impersonated_service_account_service_account_source.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/impersonated_service_account_with_quota_project.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/old_oauth_credentials_py3.pickle +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/other_cert.pem +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/pem_from_pkcs12.pem +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/privatekey.p12 +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/privatekey.pem +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/privatekey.pub +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/public_cert.pem +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/service_account.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/service_account_non_gdu.json +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/trust_chain_with_leaf.pem +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/trust_chain_without_leaf.pem +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/data/trust_chain_wrong_order.pem +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/oauth2/__init__.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/oauth2/test_utils.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test__service_account_info.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test_api_key.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test_credentials_async.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test_exceptions.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/test_packaging.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/transport/__init__.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/transport/compliance.py +0 -0
- {google_auth-2.49.0 → google_auth-3.0.0.dev0}/tests/transport/test__http_client.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: google-auth
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0.dev0
|
|
4
4
|
Summary: Google Authentication Library
|
|
5
5
|
Home-page: https://github.com/googleapis/google-auth-library-python
|
|
6
6
|
Author: Google Cloud Platform
|
|
@@ -8,6 +8,7 @@ Author-email: googleapis-packages@google.com
|
|
|
8
8
|
License: Apache 2.0
|
|
9
9
|
Keywords: google auth oauth client
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
11
12
|
Classifier: Programming Language :: Python :: 3.8
|
|
12
13
|
Classifier: Programming Language :: Python :: 3.9
|
|
13
14
|
Classifier: Programming Language :: Python :: 3.10
|
|
@@ -23,13 +24,13 @@ Classifier: Operating System :: Microsoft :: Windows
|
|
|
23
24
|
Classifier: Operating System :: MacOS :: MacOS X
|
|
24
25
|
Classifier: Operating System :: OS Independent
|
|
25
26
|
Classifier: Topic :: Internet :: WWW/HTTP
|
|
26
|
-
Requires-Python: >=3.
|
|
27
|
+
Requires-Python: >=3.7
|
|
27
28
|
License-File: LICENSE
|
|
29
|
+
Requires-Dist: cachetools<7.0,>=2.0.0
|
|
28
30
|
Requires-Dist: pyasn1-modules>=0.2.1
|
|
29
31
|
Requires-Dist: cryptography>=38.0.3
|
|
30
|
-
Requires-Dist:
|
|
32
|
+
Requires-Dist: cryptography<39.0.0; python_version < "3.8"
|
|
31
33
|
Provides-Extra: cryptography
|
|
32
|
-
Requires-Dist: cryptography>=38.0.3; extra == "cryptography"
|
|
33
34
|
Provides-Extra: aiohttp
|
|
34
35
|
Requires-Dist: aiohttp<4.0.0,>=3.6.2; extra == "aiohttp"
|
|
35
36
|
Requires-Dist: requests<3.0.0,>=2.20.0; extra == "aiohttp"
|
|
@@ -47,6 +48,7 @@ Provides-Extra: testing
|
|
|
47
48
|
Requires-Dist: grpcio; extra == "testing"
|
|
48
49
|
Requires-Dist: flask; extra == "testing"
|
|
49
50
|
Requires-Dist: freezegun; extra == "testing"
|
|
51
|
+
Requires-Dist: mock; extra == "testing"
|
|
50
52
|
Requires-Dist: oauth2client; extra == "testing"
|
|
51
53
|
Requires-Dist: pyjwt>=2.0; extra == "testing"
|
|
52
54
|
Requires-Dist: pytest; extra == "testing"
|
|
@@ -66,18 +68,6 @@ Requires-Dist: aiohttp<3.10.0; extra == "testing"
|
|
|
66
68
|
Provides-Extra: urllib3
|
|
67
69
|
Requires-Dist: urllib3; extra == "urllib3"
|
|
68
70
|
Requires-Dist: packaging; extra == "urllib3"
|
|
69
|
-
Dynamic: author
|
|
70
|
-
Dynamic: author-email
|
|
71
|
-
Dynamic: classifier
|
|
72
|
-
Dynamic: description
|
|
73
|
-
Dynamic: home-page
|
|
74
|
-
Dynamic: keywords
|
|
75
|
-
Dynamic: license
|
|
76
|
-
Dynamic: license-file
|
|
77
|
-
Dynamic: provides-extra
|
|
78
|
-
Dynamic: requires-dist
|
|
79
|
-
Dynamic: requires-python
|
|
80
|
-
Dynamic: summary
|
|
81
71
|
|
|
82
72
|
Google Auth Python Library
|
|
83
73
|
==========================
|
|
@@ -116,16 +106,15 @@ Note that the extras pyopenssl and enterprise_cert should not be used together b
|
|
|
116
106
|
|
|
117
107
|
Supported Python Versions
|
|
118
108
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
119
|
-
Python >= 3.
|
|
109
|
+
Python >= 3.7
|
|
120
110
|
|
|
121
111
|
**NOTE**:
|
|
122
|
-
Python 3.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
for download, but future releases will only target supported versions.
|
|
112
|
+
Python 3.7 was marked as `unsupported`_ by the python community in June 2023.
|
|
113
|
+
We recommend that all developers upgrade to Python 3.8 and newer as soon as
|
|
114
|
+
they can. Support for Python 3.7 will be removed from this library after
|
|
115
|
+
January 1 2024. Previous releases that support Python 3.7 will continue to be available
|
|
116
|
+
for download, but releases after January 1 2024 will only target Python 3.8 and
|
|
117
|
+
newer.
|
|
129
118
|
|
|
130
119
|
.. _unsupported: https://devguide.python.org/versions/#unsupported-versions
|
|
131
120
|
|
|
@@ -140,10 +129,6 @@ Unsupported Python Versions
|
|
|
140
129
|
- Python 3.6: The last version of this library with support for Python 3.6
|
|
141
130
|
was `google.auth == 2.22.0`.
|
|
142
131
|
|
|
143
|
-
- Python 3.7: The last version of this library with support for Python 3.7
|
|
144
|
-
was `google.auth == 2.45.0`.
|
|
145
|
-
|
|
146
|
-
|
|
147
132
|
Documentation
|
|
148
133
|
-------------
|
|
149
134
|
|
|
@@ -35,16 +35,15 @@ Note that the extras pyopenssl and enterprise_cert should not be used together b
|
|
|
35
35
|
|
|
36
36
|
Supported Python Versions
|
|
37
37
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
38
|
-
Python >= 3.
|
|
38
|
+
Python >= 3.7
|
|
39
39
|
|
|
40
40
|
**NOTE**:
|
|
41
|
-
Python 3.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
for download, but future releases will only target supported versions.
|
|
41
|
+
Python 3.7 was marked as `unsupported`_ by the python community in June 2023.
|
|
42
|
+
We recommend that all developers upgrade to Python 3.8 and newer as soon as
|
|
43
|
+
they can. Support for Python 3.7 will be removed from this library after
|
|
44
|
+
January 1 2024. Previous releases that support Python 3.7 will continue to be available
|
|
45
|
+
for download, but releases after January 1 2024 will only target Python 3.8 and
|
|
46
|
+
newer.
|
|
48
47
|
|
|
49
48
|
.. _unsupported: https://devguide.python.org/versions/#unsupported-versions
|
|
50
49
|
|
|
@@ -59,10 +58,6 @@ Unsupported Python Versions
|
|
|
59
58
|
- Python 3.6: The last version of this library with support for Python 3.6
|
|
60
59
|
was `google.auth == 2.22.0`.
|
|
61
60
|
|
|
62
|
-
- Python 3.7: The last version of this library with support for Python 3.7
|
|
63
|
-
was `google.auth == 2.45.0`.
|
|
64
|
-
|
|
65
|
-
|
|
66
61
|
Documentation
|
|
67
62
|
-------------
|
|
68
63
|
|
|
@@ -41,17 +41,13 @@ class Python37DeprecationWarning(DeprecationWarning): # pragma: NO COVER
|
|
|
41
41
|
pass
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
#
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
)
|
|
51
|
-
if sys.version_info.major == 3 and sys.version_info.minor == 8: # pragma: NO COVER
|
|
52
|
-
warnings.warn(eol_message.format("3.8"), FutureWarning)
|
|
53
|
-
elif sys.version_info.major == 3 and sys.version_info.minor == 9: # pragma: NO COVER
|
|
54
|
-
warnings.warn(eol_message.format("3.9"), FutureWarning)
|
|
44
|
+
# Checks if the current runtime is Python 3.7.
|
|
45
|
+
if sys.version_info.major == 3 and sys.version_info.minor == 7: # pragma: NO COVER
|
|
46
|
+
message = (
|
|
47
|
+
"After January 1, 2024, new releases of this library will drop support "
|
|
48
|
+
"for Python 3.7."
|
|
49
|
+
)
|
|
50
|
+
warnings.warn(message, Python37DeprecationWarning)
|
|
55
51
|
|
|
56
52
|
# Set default logging handler to avoid "No handler found" warnings.
|
|
57
53
|
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
|
@@ -24,6 +24,7 @@ from urllib.parse import quote, urlparse
|
|
|
24
24
|
|
|
25
25
|
from google.auth import environment_vars
|
|
26
26
|
from google.auth import exceptions
|
|
27
|
+
from google.auth.transport import _mtls_helper
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
_LOGGER = logging.getLogger(__name__)
|
|
@@ -262,6 +263,14 @@ def should_request_bound_token(cert):
|
|
|
262
263
|
return is_agent_cert and is_opted_in
|
|
263
264
|
|
|
264
265
|
|
|
266
|
+
def call_client_cert_callback():
|
|
267
|
+
"""Calls the client cert callback and returns the certificate and key."""
|
|
268
|
+
_, cert_bytes, key_bytes, passphrase = _mtls_helper.get_client_ssl_credentials(
|
|
269
|
+
generate_encrypted_key=True
|
|
270
|
+
)
|
|
271
|
+
return cert_bytes, key_bytes
|
|
272
|
+
|
|
273
|
+
|
|
265
274
|
def get_cached_cert_fingerprint(cached_cert):
|
|
266
275
|
"""Returns the fingerprint of the cached certificate."""
|
|
267
276
|
if cached_cert:
|
|
@@ -16,23 +16,17 @@
|
|
|
16
16
|
|
|
17
17
|
Implements application default credentials and project ID detection.
|
|
18
18
|
"""
|
|
19
|
-
from __future__ import annotations
|
|
20
19
|
|
|
21
20
|
import io
|
|
22
21
|
import json
|
|
23
22
|
import logging
|
|
24
23
|
import os
|
|
25
|
-
from typing import Optional, Sequence, TYPE_CHECKING
|
|
26
24
|
import warnings
|
|
27
25
|
|
|
28
26
|
from google.auth import environment_vars
|
|
29
27
|
from google.auth import exceptions
|
|
30
28
|
import google.auth.transport._http_client
|
|
31
29
|
|
|
32
|
-
if TYPE_CHECKING: # pragma: NO COVER
|
|
33
|
-
from google.auth.credentials import Credentials # noqa: F401
|
|
34
|
-
from google.auth.transport import Request # noqa: F401
|
|
35
|
-
|
|
36
30
|
_LOGGER = logging.getLogger(__name__)
|
|
37
31
|
|
|
38
32
|
# Valid types accepted for file-based credentials.
|
|
@@ -330,24 +324,23 @@ def _get_explicit_environ_credentials(quota_project_id=None):
|
|
|
330
324
|
from google.auth import _cloud_sdk
|
|
331
325
|
|
|
332
326
|
cloud_sdk_adc_path = _cloud_sdk.get_application_default_credentials_path()
|
|
333
|
-
explicit_file = os.environ.get(environment_vars.CREDENTIALS
|
|
327
|
+
explicit_file = os.environ.get(environment_vars.CREDENTIALS)
|
|
334
328
|
|
|
335
329
|
_LOGGER.debug(
|
|
336
|
-
"Checking
|
|
337
|
-
explicit_file,
|
|
330
|
+
"Checking %s for explicit credentials as part of auth process...", explicit_file
|
|
338
331
|
)
|
|
339
332
|
|
|
340
|
-
if explicit_file
|
|
333
|
+
if explicit_file is not None and explicit_file == cloud_sdk_adc_path:
|
|
341
334
|
# Cloud sdk flow calls gcloud to fetch project id, so if the explicit
|
|
342
335
|
# file path is cloud sdk credentials path, then we should fall back
|
|
343
336
|
# to cloud sdk flow, otherwise project id cannot be obtained.
|
|
344
337
|
_LOGGER.debug(
|
|
345
|
-
"Explicit credentials path
|
|
338
|
+
"Explicit credentials path %s is the same as Cloud SDK credentials path, fall back to Cloud SDK credentials flow...",
|
|
346
339
|
explicit_file,
|
|
347
340
|
)
|
|
348
341
|
return _get_gcloud_sdk_credentials(quota_project_id=quota_project_id)
|
|
349
342
|
|
|
350
|
-
if explicit_file
|
|
343
|
+
if explicit_file is not None:
|
|
351
344
|
with warnings.catch_warnings():
|
|
352
345
|
warnings.simplefilter("ignore", DeprecationWarning)
|
|
353
346
|
credentials, project_id = load_credentials_from_file(
|
|
@@ -355,6 +348,7 @@ def _get_explicit_environ_credentials(quota_project_id=None):
|
|
|
355
348
|
quota_project_id=quota_project_id,
|
|
356
349
|
)
|
|
357
350
|
credentials._cred_file_path = f"{explicit_file} file via the GOOGLE_APPLICATION_CREDENTIALS environment variable"
|
|
351
|
+
|
|
358
352
|
return credentials, project_id
|
|
359
353
|
|
|
360
354
|
else:
|
|
@@ -594,12 +588,7 @@ def _apply_quota_project_id(credentials, quota_project_id):
|
|
|
594
588
|
return credentials
|
|
595
589
|
|
|
596
590
|
|
|
597
|
-
def default(
|
|
598
|
-
scopes: Optional[Sequence[str]] = None,
|
|
599
|
-
request: Optional["google.auth.transport.Request"] = None,
|
|
600
|
-
quota_project_id: Optional[str] = None,
|
|
601
|
-
default_scopes: Optional[Sequence[str]] = None,
|
|
602
|
-
) -> tuple["google.auth.credentials.Credentials", Optional[str]]:
|
|
591
|
+
def default(scopes=None, request=None, quota_project_id=None, default_scopes=None):
|
|
603
592
|
"""Gets the default credentials for the current environment.
|
|
604
593
|
|
|
605
594
|
`Application Default Credentials`_ provides an easy way to obtain
|
|
@@ -124,26 +124,6 @@ def utcnow():
|
|
|
124
124
|
return now
|
|
125
125
|
|
|
126
126
|
|
|
127
|
-
def utcfromtimestamp(timestamp):
|
|
128
|
-
"""Returns the UTC datetime from a timestamp.
|
|
129
|
-
|
|
130
|
-
Args:
|
|
131
|
-
timestamp (float): The timestamp to convert.
|
|
132
|
-
|
|
133
|
-
Returns:
|
|
134
|
-
datetime: The time in UTC.
|
|
135
|
-
"""
|
|
136
|
-
# We used datetime.utcfromtimestamp() before, since it's deprecated from
|
|
137
|
-
# python 3.12, we are using datetime.fromtimestamp(timestamp, timezone.utc)
|
|
138
|
-
# now. "utcfromtimestamp()" is offset-native (no timezone info), but
|
|
139
|
-
# "fromtimestamp(timestamp, timezone.utc)" is offset-aware (with timezone
|
|
140
|
-
# info). This will cause datetime comparison problem. For backward
|
|
141
|
-
# compatibility, we need to remove the timezone info.
|
|
142
|
-
dt = datetime.datetime.fromtimestamp(timestamp, tz=datetime.timezone.utc)
|
|
143
|
-
dt = dt.replace(tzinfo=None)
|
|
144
|
-
return dt
|
|
145
|
-
|
|
146
|
-
|
|
147
127
|
def datetime_to_secs(value):
|
|
148
128
|
"""Convert a datetime object to the number of seconds since the UNIX epoch.
|
|
149
129
|
|
|
@@ -354,8 +334,7 @@ def is_python_3():
|
|
|
354
334
|
Returns:
|
|
355
335
|
bool: True if the Python interpreter is Python 3 and False otherwise.
|
|
356
336
|
"""
|
|
357
|
-
|
|
358
|
-
return sys.version_info > (3, 0) # pragma: NO COVER
|
|
337
|
+
return sys.version_info > (3, 0)
|
|
359
338
|
|
|
360
339
|
|
|
361
340
|
def _hash_sensitive_info(data: Union[dict, list]) -> Union[dict, list, str]:
|
|
@@ -12,11 +12,12 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
"""Transport adapter for Asynchronous HTTP Requests based on aiohttp.
|
|
15
|
+
"""Transport adapter for Asynchronous HTTP Requests based on aiohttp.
|
|
16
|
+
"""
|
|
16
17
|
|
|
17
18
|
import asyncio
|
|
18
19
|
import logging
|
|
19
|
-
from typing import AsyncGenerator, Mapping, Optional
|
|
20
|
+
from typing import AsyncGenerator, Mapping, Optional
|
|
20
21
|
|
|
21
22
|
try:
|
|
22
23
|
import aiohttp # type: ignore
|
|
@@ -30,15 +31,6 @@ from google.auth import exceptions
|
|
|
30
31
|
from google.auth.aio import _helpers as _helpers_async
|
|
31
32
|
from google.auth.aio import transport
|
|
32
33
|
|
|
33
|
-
if TYPE_CHECKING: # pragma: NO COVER
|
|
34
|
-
from aiohttp import ClientTimeout # type: ignore
|
|
35
|
-
|
|
36
|
-
else:
|
|
37
|
-
try:
|
|
38
|
-
from aiohttp import ClientTimeout
|
|
39
|
-
except (ImportError, AttributeError):
|
|
40
|
-
ClientTimeout = None
|
|
41
|
-
|
|
42
34
|
_LOGGER = logging.getLogger(__name__)
|
|
43
35
|
|
|
44
36
|
|
|
@@ -112,7 +104,7 @@ class Request(transport.Request):
|
|
|
112
104
|
# Custom aiohttp Session Example:
|
|
113
105
|
session = session=aiohttp.ClientSession(auto_decompress=False)
|
|
114
106
|
request = google.auth.aio.transport.aiohttp.Request(session=session)
|
|
115
|
-
|
|
107
|
+
auth_sesion = google.auth.aio.transport.sessions.AsyncAuthorizedSession(auth_request=request)
|
|
116
108
|
|
|
117
109
|
Args:
|
|
118
110
|
session (aiohttp.ClientSession): An instance :class:`aiohttp.ClientSession` used
|
|
@@ -121,7 +113,7 @@ class Request(transport.Request):
|
|
|
121
113
|
.. automethod:: __call__
|
|
122
114
|
"""
|
|
123
115
|
|
|
124
|
-
def __init__(self, session:
|
|
116
|
+
def __init__(self, session: aiohttp.ClientSession = None):
|
|
125
117
|
self._session = session
|
|
126
118
|
self._closed = False
|
|
127
119
|
|
|
@@ -131,7 +123,7 @@ class Request(transport.Request):
|
|
|
131
123
|
method: str = "GET",
|
|
132
124
|
body: Optional[bytes] = None,
|
|
133
125
|
headers: Optional[Mapping[str, str]] = None,
|
|
134
|
-
timeout:
|
|
126
|
+
timeout: float = transport._DEFAULT_TIMEOUT_SECONDS,
|
|
135
127
|
**kwargs,
|
|
136
128
|
) -> transport.Response:
|
|
137
129
|
"""
|
|
@@ -166,10 +158,7 @@ class Request(transport.Request):
|
|
|
166
158
|
if not self._session:
|
|
167
159
|
self._session = aiohttp.ClientSession()
|
|
168
160
|
|
|
169
|
-
|
|
170
|
-
client_timeout = timeout
|
|
171
|
-
else:
|
|
172
|
-
client_timeout = aiohttp.ClientTimeout(total=timeout)
|
|
161
|
+
client_timeout = aiohttp.ClientTimeout(total=timeout)
|
|
173
162
|
_helpers.request_log(_LOGGER, method, url, body, headers)
|
|
174
163
|
response = await self._session.request(
|
|
175
164
|
method,
|
|
@@ -187,12 +176,8 @@ class Request(transport.Request):
|
|
|
187
176
|
raise client_exc from caught_exc
|
|
188
177
|
|
|
189
178
|
except asyncio.TimeoutError as caught_exc:
|
|
190
|
-
if isinstance(timeout, aiohttp.ClientTimeout):
|
|
191
|
-
timeout_seconds = timeout.total
|
|
192
|
-
else:
|
|
193
|
-
timeout_seconds = timeout
|
|
194
179
|
timeout_exc = exceptions.TimeoutError(
|
|
195
|
-
f"Request timed out after {
|
|
180
|
+
f"Request timed out after {timeout} seconds."
|
|
196
181
|
)
|
|
197
182
|
raise timeout_exc from caught_exc
|
|
198
183
|
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
# Copyright 2024 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
import asyncio
|
|
16
|
+
from contextlib import asynccontextmanager
|
|
17
|
+
import functools
|
|
18
|
+
import time
|
|
19
|
+
from typing import Mapping, Optional
|
|
20
|
+
|
|
21
|
+
from google.auth import _exponential_backoff, exceptions
|
|
22
|
+
from google.auth.aio import transport
|
|
23
|
+
from google.auth.aio.credentials import Credentials
|
|
24
|
+
from google.auth.exceptions import TimeoutError
|
|
25
|
+
|
|
26
|
+
try:
|
|
27
|
+
from google.auth.aio.transport.aiohttp import Request as AiohttpRequest
|
|
28
|
+
|
|
29
|
+
AIOHTTP_INSTALLED = True
|
|
30
|
+
except ImportError: # pragma: NO COVER
|
|
31
|
+
AIOHTTP_INSTALLED = False
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@asynccontextmanager
|
|
35
|
+
async def timeout_guard(timeout):
|
|
36
|
+
"""
|
|
37
|
+
timeout_guard is an asynchronous context manager to apply a timeout to an asynchronous block of code.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
timeout (float): The time in seconds before the context manager times out.
|
|
41
|
+
|
|
42
|
+
Raises:
|
|
43
|
+
google.auth.exceptions.TimeoutError: If the code within the context exceeds the provided timeout.
|
|
44
|
+
|
|
45
|
+
Usage:
|
|
46
|
+
async with timeout_guard(10) as with_timeout:
|
|
47
|
+
await with_timeout(async_function())
|
|
48
|
+
"""
|
|
49
|
+
start = time.monotonic()
|
|
50
|
+
total_timeout = timeout
|
|
51
|
+
|
|
52
|
+
def _remaining_time():
|
|
53
|
+
elapsed = time.monotonic() - start
|
|
54
|
+
remaining = total_timeout - elapsed
|
|
55
|
+
if remaining <= 0:
|
|
56
|
+
raise TimeoutError(
|
|
57
|
+
f"Context manager exceeded the configured timeout of {total_timeout}s."
|
|
58
|
+
)
|
|
59
|
+
return remaining
|
|
60
|
+
|
|
61
|
+
async def with_timeout(coro):
|
|
62
|
+
try:
|
|
63
|
+
remaining = _remaining_time()
|
|
64
|
+
response = await asyncio.wait_for(coro, remaining)
|
|
65
|
+
return response
|
|
66
|
+
except (asyncio.TimeoutError, TimeoutError) as e:
|
|
67
|
+
raise TimeoutError(
|
|
68
|
+
f"The operation {coro} exceeded the configured timeout of {total_timeout}s."
|
|
69
|
+
) from e
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
yield with_timeout
|
|
73
|
+
|
|
74
|
+
finally:
|
|
75
|
+
_remaining_time()
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class AsyncAuthorizedSession:
|
|
79
|
+
"""This is an asynchronous implementation of :class:`google.auth.requests.AuthorizedSession` class.
|
|
80
|
+
We utilize an instance of a class that implements :class:`google.auth.aio.transport.Request` configured
|
|
81
|
+
by the caller or otherwise default to `google.auth.aio.transport.aiohttp.Request` if the external aiohttp
|
|
82
|
+
package is installed.
|
|
83
|
+
|
|
84
|
+
A Requests Session class with credentials.
|
|
85
|
+
|
|
86
|
+
This class is used to perform asynchronous requests to API endpoints that require
|
|
87
|
+
authorization::
|
|
88
|
+
|
|
89
|
+
import aiohttp
|
|
90
|
+
from google.auth.aio.transport import sessions
|
|
91
|
+
|
|
92
|
+
async with sessions.AsyncAuthorizedSession(credentials) as authed_session:
|
|
93
|
+
response = await authed_session.request(
|
|
94
|
+
'GET', 'https://www.googleapis.com/storage/v1/b')
|
|
95
|
+
|
|
96
|
+
The underlying :meth:`request` implementation handles adding the
|
|
97
|
+
credentials' headers to the request and refreshing credentials as needed.
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
credentials (google.auth.aio.credentials.Credentials):
|
|
101
|
+
The credentials to add to the request.
|
|
102
|
+
auth_request (Optional[google.auth.aio.transport.Request]):
|
|
103
|
+
An instance of a class that implements
|
|
104
|
+
:class:`~google.auth.aio.transport.Request` used to make requests
|
|
105
|
+
and refresh credentials. If not passed,
|
|
106
|
+
an instance of :class:`~google.auth.aio.transport.aiohttp.Request`
|
|
107
|
+
is created.
|
|
108
|
+
|
|
109
|
+
Raises:
|
|
110
|
+
- google.auth.exceptions.TransportError: If `auth_request` is `None`
|
|
111
|
+
and the external package `aiohttp` is not installed.
|
|
112
|
+
- google.auth.exceptions.InvalidType: If the provided credentials are
|
|
113
|
+
not of type `google.auth.aio.credentials.Credentials`.
|
|
114
|
+
"""
|
|
115
|
+
|
|
116
|
+
def __init__(
|
|
117
|
+
self, credentials: Credentials, auth_request: Optional[transport.Request] = None
|
|
118
|
+
):
|
|
119
|
+
if not isinstance(credentials, Credentials):
|
|
120
|
+
raise exceptions.InvalidType(
|
|
121
|
+
f"The configured credentials of type {type(credentials)} are invalid and must be of type `google.auth.aio.credentials.Credentials`"
|
|
122
|
+
)
|
|
123
|
+
self._credentials = credentials
|
|
124
|
+
_auth_request = auth_request
|
|
125
|
+
if not _auth_request and AIOHTTP_INSTALLED:
|
|
126
|
+
_auth_request = AiohttpRequest()
|
|
127
|
+
if _auth_request is None:
|
|
128
|
+
raise exceptions.TransportError(
|
|
129
|
+
"`auth_request` must either be configured or the external package `aiohttp` must be installed to use the default value."
|
|
130
|
+
)
|
|
131
|
+
self._auth_request = _auth_request
|
|
132
|
+
|
|
133
|
+
async def request(
|
|
134
|
+
self,
|
|
135
|
+
method: str,
|
|
136
|
+
url: str,
|
|
137
|
+
data: Optional[bytes] = None,
|
|
138
|
+
headers: Optional[Mapping[str, str]] = None,
|
|
139
|
+
max_allowed_time: float = transport._DEFAULT_TIMEOUT_SECONDS,
|
|
140
|
+
timeout: float = transport._DEFAULT_TIMEOUT_SECONDS,
|
|
141
|
+
**kwargs,
|
|
142
|
+
) -> transport.Response:
|
|
143
|
+
"""
|
|
144
|
+
Args:
|
|
145
|
+
method (str): The http method used to make the request.
|
|
146
|
+
url (str): The URI to be requested.
|
|
147
|
+
data (Optional[bytes]): The payload or body in HTTP request.
|
|
148
|
+
headers (Optional[Mapping[str, str]]): Request headers.
|
|
149
|
+
timeout (float):
|
|
150
|
+
The amount of time in seconds to wait for the server response
|
|
151
|
+
with each individual request.
|
|
152
|
+
max_allowed_time (float):
|
|
153
|
+
If the method runs longer than this, a ``Timeout`` exception is
|
|
154
|
+
automatically raised. Unlike the ``timeout`` parameter, this
|
|
155
|
+
value applies to the total method execution time, even if
|
|
156
|
+
multiple requests are made under the hood.
|
|
157
|
+
|
|
158
|
+
Mind that it is not guaranteed that the timeout error is raised
|
|
159
|
+
at ``max_allowed_time``. It might take longer, for example, if
|
|
160
|
+
an underlying request takes a lot of time, but the request
|
|
161
|
+
itself does not timeout, e.g. if a large file is being
|
|
162
|
+
transmitted. The timout error will be raised after such
|
|
163
|
+
request completes.
|
|
164
|
+
|
|
165
|
+
Returns:
|
|
166
|
+
google.auth.aio.transport.Response: The HTTP response.
|
|
167
|
+
|
|
168
|
+
Raises:
|
|
169
|
+
google.auth.exceptions.TimeoutError: If the method does not complete within
|
|
170
|
+
the configured `max_allowed_time` or the request exceeds the configured
|
|
171
|
+
`timeout`.
|
|
172
|
+
"""
|
|
173
|
+
|
|
174
|
+
retries = _exponential_backoff.AsyncExponentialBackoff(
|
|
175
|
+
total_attempts=transport.DEFAULT_MAX_RETRY_ATTEMPTS
|
|
176
|
+
)
|
|
177
|
+
async with timeout_guard(max_allowed_time) as with_timeout:
|
|
178
|
+
await with_timeout(
|
|
179
|
+
# Note: before_request will attempt to refresh credentials if expired.
|
|
180
|
+
self._credentials.before_request(
|
|
181
|
+
self._auth_request, method, url, headers
|
|
182
|
+
)
|
|
183
|
+
)
|
|
184
|
+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
|
|
185
|
+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
|
|
186
|
+
async for _ in retries: # pragma: no branch
|
|
187
|
+
response = await with_timeout(
|
|
188
|
+
self._auth_request(url, method, data, headers, timeout, **kwargs)
|
|
189
|
+
)
|
|
190
|
+
if response.status_code not in transport.DEFAULT_RETRYABLE_STATUS_CODES:
|
|
191
|
+
break
|
|
192
|
+
return response
|
|
193
|
+
|
|
194
|
+
@functools.wraps(request)
|
|
195
|
+
async def get(
|
|
196
|
+
self,
|
|
197
|
+
url: str,
|
|
198
|
+
data: Optional[bytes] = None,
|
|
199
|
+
headers: Optional[Mapping[str, str]] = None,
|
|
200
|
+
max_allowed_time: float = transport._DEFAULT_TIMEOUT_SECONDS,
|
|
201
|
+
timeout: float = transport._DEFAULT_TIMEOUT_SECONDS,
|
|
202
|
+
**kwargs,
|
|
203
|
+
) -> transport.Response:
|
|
204
|
+
return await self.request(
|
|
205
|
+
"GET", url, data, headers, max_allowed_time, timeout, **kwargs
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
@functools.wraps(request)
|
|
209
|
+
async def post(
|
|
210
|
+
self,
|
|
211
|
+
url: str,
|
|
212
|
+
data: Optional[bytes] = None,
|
|
213
|
+
headers: Optional[Mapping[str, str]] = None,
|
|
214
|
+
max_allowed_time: float = transport._DEFAULT_TIMEOUT_SECONDS,
|
|
215
|
+
timeout: float = transport._DEFAULT_TIMEOUT_SECONDS,
|
|
216
|
+
**kwargs,
|
|
217
|
+
) -> transport.Response:
|
|
218
|
+
return await self.request(
|
|
219
|
+
"POST", url, data, headers, max_allowed_time, timeout, **kwargs
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
@functools.wraps(request)
|
|
223
|
+
async def put(
|
|
224
|
+
self,
|
|
225
|
+
url: str,
|
|
226
|
+
data: Optional[bytes] = None,
|
|
227
|
+
headers: Optional[Mapping[str, str]] = None,
|
|
228
|
+
max_allowed_time: float = transport._DEFAULT_TIMEOUT_SECONDS,
|
|
229
|
+
timeout: float = transport._DEFAULT_TIMEOUT_SECONDS,
|
|
230
|
+
**kwargs,
|
|
231
|
+
) -> transport.Response:
|
|
232
|
+
return await self.request(
|
|
233
|
+
"PUT", url, data, headers, max_allowed_time, timeout, **kwargs
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
@functools.wraps(request)
|
|
237
|
+
async def patch(
|
|
238
|
+
self,
|
|
239
|
+
url: str,
|
|
240
|
+
data: Optional[bytes] = None,
|
|
241
|
+
headers: Optional[Mapping[str, str]] = None,
|
|
242
|
+
max_allowed_time: float = transport._DEFAULT_TIMEOUT_SECONDS,
|
|
243
|
+
timeout: float = transport._DEFAULT_TIMEOUT_SECONDS,
|
|
244
|
+
**kwargs,
|
|
245
|
+
) -> transport.Response:
|
|
246
|
+
return await self.request(
|
|
247
|
+
"PATCH", url, data, headers, max_allowed_time, timeout, **kwargs
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
@functools.wraps(request)
|
|
251
|
+
async def delete(
|
|
252
|
+
self,
|
|
253
|
+
url: str,
|
|
254
|
+
data: Optional[bytes] = None,
|
|
255
|
+
headers: Optional[Mapping[str, str]] = None,
|
|
256
|
+
max_allowed_time: float = transport._DEFAULT_TIMEOUT_SECONDS,
|
|
257
|
+
timeout: float = transport._DEFAULT_TIMEOUT_SECONDS,
|
|
258
|
+
**kwargs,
|
|
259
|
+
) -> transport.Response:
|
|
260
|
+
return await self.request(
|
|
261
|
+
"DELETE", url, data, headers, max_allowed_time, timeout, **kwargs
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
async def close(self) -> None:
|
|
265
|
+
"""
|
|
266
|
+
Close the underlying auth request session.
|
|
267
|
+
"""
|
|
268
|
+
await self._auth_request.close()
|
|
@@ -22,6 +22,7 @@ Engine in the standard environment using the `App Identity API`_.
|
|
|
22
22
|
https://cloud.google.com/appengine/docs/python/appidentity/
|
|
23
23
|
"""
|
|
24
24
|
|
|
25
|
+
import datetime
|
|
25
26
|
|
|
26
27
|
from google.auth import _helpers
|
|
27
28
|
from google.auth import credentials
|
|
@@ -127,7 +128,7 @@ class Credentials(
|
|
|
127
128
|
scopes = self._scopes if self._scopes is not None else self._default_scopes
|
|
128
129
|
# pylint: disable=unused-argument
|
|
129
130
|
token, ttl = app_identity.get_access_token(scopes, self._service_account_id)
|
|
130
|
-
expiry =
|
|
131
|
+
expiry = datetime.datetime.utcfromtimestamp(ttl)
|
|
131
132
|
|
|
132
133
|
self.token, self.expiry = token, expiry
|
|
133
134
|
|
|
@@ -530,10 +530,9 @@ class _DefaultAwsSecurityCredentialsSupplier(AwsSecurityCredentialsSupplier):
|
|
|
530
530
|
google.auth.exceptions.RefreshError: If an error occurs while
|
|
531
531
|
retrieving the AWS security credentials.
|
|
532
532
|
"""
|
|
533
|
+
headers = {"Content-Type": "application/json"}
|
|
533
534
|
if imdsv2_session_token is not None:
|
|
534
|
-
headers
|
|
535
|
-
else:
|
|
536
|
-
headers = None
|
|
535
|
+
headers["X-aws-ec2-metadata-token"] = imdsv2_session_token
|
|
537
536
|
|
|
538
537
|
response = request(
|
|
539
538
|
url="{}/{}".format(self._security_credentials_url, role_name),
|