3 L(ÌYÖã@sfdZddlZddlmZddlmZddlmZdZdZdd „Z defd d „Z dd d „Z ddd„Z dS)zGoogle ID Token helpers.éN)Ú http_client)Ú exceptions)Újwtz*https://www.googleapis.com/oauth2/v1/certszXhttps://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.comcCs:||dd�}|jtjkr(tjdj|ƒƒ‚tj|jj dƒƒS)a—Fetches certificates. Google-style cerificate endpoints return JSON in the format of ``{'key id': 'x509 certificate'}``. Args: request (google.auth.transport.Request): The object used to make HTTP requests. certs_url (str): The certificate endpoint URL. Returns: Mapping[str, str]: A mapping of public key ID to x.509 certificate data. ÚGET)Úmethodz"Could not fetch certificates at {}zutf-8) ÚstatusrÚOKrZTransportErrorÚformatÚjsonÚloadsÚdataÚdecode)ÚrequestÚ certs_urlÚresponse©rúE/private/tmp/pip-build-nl73fm5q/google-auth/google/oauth2/id_token.pyÚ _fetch_certs#s    rcCst||ƒ}tj|||d�S)a_Verifies an ID token and returns the decoded token. Args: id_token (Union[str, bytes]): The encoded token. request (google.auth.transport.Request): The object used to make HTTP requests. audience (str): The audience that this token is intended for. If None then the audience is not verified. certs_url (str): The URL that specifies the certificates to use to verify the token. This URL should return JSON in the format of ``{'key id': 'x509 certificate'}``. Returns: Mapping[str, Any]: The decoded token. )ÚcertsÚaudience)rrr )Úid_tokenrrrrrrrÚ verify_token;s rcCst|||td�S)aóVerifies an ID Token issued by Google's OAuth 2.0 authorization server. Args: id_token (Union[str, bytes]): The encoded token. request (google.auth.transport.Request): The object used to make HTTP requests. audience (str): The audience that this token is intended for. This is typically your application's OAuth 2.0 client ID. If None then the audience is not verified. Returns: Mapping[str, Any]: The decoded token. )rr)rÚ_GOOGLE_OAUTH2_CERTS_URL)rrrrrrÚverify_oauth2_tokenQsrcCst|||td�S)aÙVerifies an ID Token issued by Firebase Authentication. Args: id_token (Union[str, bytes]): The encoded token. request (google.auth.transport.Request): The object used to make HTTP requests. audience (str): The audience that this token is intended for. This is typically your Firebase application ID. If None then the audience is not verified. Returns: Mapping[str, Any]: The decoded token. )rr)rÚ_GOOGLE_APIS_CERTS_URL)rrrrrrÚverify_firebase_tokendsr)N)N) Ú__doc__r Z six.movesrZ google.authrrrrrrrrrrrrÚs