From bdc9badfbf5d9bd1ecd22aa5d7daa7b91be24ddb Mon Sep 17 00:00:00 2001 From: arithmetic1728 Date: Tue, 30 Mar 2021 03:16:23 -0700 Subject: [PATCH] update --- google/oauth2/_client.py | 7 +------ google/oauth2/challenges.py | 3 +-- google/oauth2/reauth.py | 10 +++++----- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/google/oauth2/_client.py b/google/oauth2/_client.py index 8ef5dbe89..add563f29 100644 --- a/google/oauth2/_client.py +++ b/google/oauth2/_client.py @@ -23,11 +23,6 @@ .. _Section 3.1 of rfc6749: https://tools.ietf.org/html/rfc6749#section-3.2 """ -try: - from collections.abc import Mapping -# Python 2.7 compatibility -except ImportError: # pragma: NO COVER - from collections import Mapping import datetime import json @@ -112,7 +107,7 @@ def _token_endpoint_request_no_throw( body = urllib.parse.urlencode(body).encode("utf-8") if access_token: - headers["Authorization"] = f"Bearer {access_token}" + headers["Authorization"] = "Bearer {}".format(access_token) retry = 0 # retry to fetch token for maximum of two times if any internal failure diff --git a/google/oauth2/challenges.py b/google/oauth2/challenges.py index b11e6e925..1613b3f5b 100644 --- a/google/oauth2/challenges.py +++ b/google/oauth2/challenges.py @@ -19,7 +19,6 @@ import base64 import getpass import sys -import warnings import six @@ -97,7 +96,7 @@ def obtain_challenge_input(self, metadata): import pyu2f.convenience.authenticator import pyu2f.errors import pyu2f.model - except ImportError as e: + except ImportError: sys.stderr.write( "pyu2f is missing. Please install pyu2f to use Security key reauth feature." ) diff --git a/google/oauth2/reauth.py b/google/oauth2/reauth.py index 98fbfba27..117e3c07d 100644 --- a/google/oauth2/reauth.py +++ b/google/oauth2/reauth.py @@ -32,13 +32,13 @@ 3. Refreshing the access token using the returned rapt token. """ -import json import sys +from six.moves import range + from google.auth import exceptions -from google.oauth2 import challenges from google.oauth2 import _client -from six.moves import range +from google.oauth2 import challenges _REAUTH_SCOPE = "https://www.googleapis.com/auth/accounts.reauth" @@ -104,7 +104,7 @@ def _send_challenge_result( return _client._token_endpoint_request( request, - _REAUTH_API + f"/{session_id}:continue", + _REAUTH_API + "/{}:continue".format(session_id), body, access_token=access_token, use_json=True, @@ -198,7 +198,7 @@ def _obtain_rapt(request, access_token, requested_scopes, rounds_num=5): msg["status"] == _CHALLENGE_REQUIRED or msg["status"] == _CHALLENGE_PENDING ): raise exceptions.ReauthFailError( - f"Reauthentication challenge failed due to API error: {0}".format( + "Reauthentication challenge failed due to API error: {}".format( msg["status"] ) )