File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 8080from google .oauth2 import _client
8181
8282_DEFAULT_TOKEN_LIFETIME_SECS = 3600 # 1 hour in seconds
83+ _GOOGLE_OAUTH2_TOKEN_ENDPOINT = "https://oauth2.googleapis.com/token"
8384
8485
8586class Credentials (
@@ -382,7 +383,7 @@ def _make_authorization_grant_assertion(self):
382383 # The issuer must be the service account email.
383384 "iss" : self ._service_account_email ,
384385 # The audience must be the auth token endpoint's URI
385- "aud" : self . _token_uri ,
386+ "aud" : _GOOGLE_OAUTH2_TOKEN_ENDPOINT ,
386387 "scope" : _helpers .scopes_to_string (self ._scopes or ()),
387388 }
388389
@@ -643,7 +644,7 @@ def _make_authorization_grant_assertion(self):
643644 # The issuer must be the service account email.
644645 "iss" : self .service_account_email ,
645646 # The audience must be the auth token endpoint's URI
646- "aud" : self . _token_uri ,
647+ "aud" : _GOOGLE_OAUTH2_TOKEN_ENDPOINT ,
647648 # The target audience specifies which service the ID token is
648649 # intended for.
649650 "target_audience" : self ._target_audience ,
Original file line number Diff line number Diff line change @@ -167,7 +167,7 @@ def test__make_authorization_grant_assertion(self):
167167 token = credentials ._make_authorization_grant_assertion ()
168168 payload = jwt .decode (token , PUBLIC_CERT_BYTES )
169169 assert payload ["iss" ] == self .SERVICE_ACCOUNT_EMAIL
170- assert payload ["aud" ] == self . TOKEN_URI
170+ assert payload ["aud" ] == service_account . _GOOGLE_OAUTH2_TOKEN_ENDPOINT
171171
172172 def test__make_authorization_grant_assertion_scoped (self ):
173173 credentials = self .make_credentials ()
@@ -440,7 +440,7 @@ def test__make_authorization_grant_assertion(self):
440440 token = credentials ._make_authorization_grant_assertion ()
441441 payload = jwt .decode (token , PUBLIC_CERT_BYTES )
442442 assert payload ["iss" ] == self .SERVICE_ACCOUNT_EMAIL
443- assert payload ["aud" ] == self . TOKEN_URI
443+ assert payload ["aud" ] == service_account . _GOOGLE_OAUTH2_TOKEN_ENDPOINT
444444 assert payload ["target_audience" ] == self .TARGET_AUDIENCE
445445
446446 @mock .patch ("google.oauth2._client.id_token_jwt_grant" , autospec = True )
Original file line number Diff line number Diff line change @@ -152,7 +152,10 @@ def test__make_authorization_grant_assertion(self):
152152 token = credentials ._make_authorization_grant_assertion ()
153153 payload = jwt .decode (token , test_service_account .PUBLIC_CERT_BYTES )
154154 assert payload ["iss" ] == self .SERVICE_ACCOUNT_EMAIL
155- assert payload ["aud" ] == self .TOKEN_URI
155+ assert (
156+ payload ["aud" ]
157+ == service_account .service_account ._GOOGLE_OAUTH2_TOKEN_ENDPOINT
158+ )
156159
157160 def test__make_authorization_grant_assertion_scoped (self ):
158161 credentials = self .make_credentials ()
@@ -311,7 +314,10 @@ def test__make_authorization_grant_assertion(self):
311314 token = credentials ._make_authorization_grant_assertion ()
312315 payload = jwt .decode (token , test_service_account .PUBLIC_CERT_BYTES )
313316 assert payload ["iss" ] == self .SERVICE_ACCOUNT_EMAIL
314- assert payload ["aud" ] == self .TOKEN_URI
317+ assert (
318+ payload ["aud" ]
319+ == service_account .service_account ._GOOGLE_OAUTH2_TOKEN_ENDPOINT
320+ )
315321 assert payload ["target_audience" ] == self .TARGET_AUDIENCE
316322
317323 @mock .patch ("google.oauth2._client_async.id_token_jwt_grant" , autospec = True )
You can’t perform that action at this time.
0 commit comments