Skip to content

Commit cb5cba6

Browse files
mbassiounyJon Wayne Parrott
authored andcommitted
Fix OAuth2 credentials to inherit from ReadOnlyScoped instead of Scoped. (#200)
* Fix OAuth2 credentials to inherit from ReadOnlyScoped instead of Scoped. * Remove unused pytest
1 parent cddc665 commit cb5cba6

File tree

2 files changed

+1
-16
lines changed

2 files changed

+1
-16
lines changed

packages/google-auth/google/oauth2/credentials.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from google.oauth2 import _client
3737

3838

39-
class Credentials(credentials.Scoped, credentials.Credentials):
39+
class Credentials(credentials.ReadOnlyScoped, credentials.Credentials):
4040
"""Credentials using OAuth 2.0 access and refresh tokens."""
4141

4242
def __init__(self, token, refresh_token=None, id_token=None,
@@ -109,15 +109,6 @@ def requires_scopes(self):
109109
the initial token is requested and can not be changed."""
110110
return False
111111

112-
def with_scopes(self, scopes):
113-
"""Unavailable, OAuth 2.0 credentials can not be re-scoped.
114-
115-
OAuth 2.0 credentials have their scopes set when the initial token is
116-
requested and can not be changed.
117-
"""
118-
raise NotImplementedError(
119-
'OAuth 2.0 Credentials can not modify their scopes.')
120-
121112
@_helpers.copy_docstring(credentials.Credentials)
122113
def refresh(self, request):
123114
access_token, refresh_token, expiry, grant_response = (

packages/google-auth/tests/oauth2/test_credentials.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import datetime
1616

1717
import mock
18-
import pytest
1918

2019
from google.auth import _helpers
2120
from google.auth import transport
@@ -48,11 +47,6 @@ def test_default_state(self):
4847
assert credentials.client_id == self.CLIENT_ID
4948
assert credentials.client_secret == self.CLIENT_SECRET
5049

51-
def test_create_scoped(self):
52-
credentials = self.make_credentials()
53-
with pytest.raises(NotImplementedError):
54-
credentials.with_scopes(['email'])
55-
5650
@mock.patch('google.oauth2._client.refresh_grant', autospec=True)
5751
@mock.patch(
5852
'google.auth._helpers.utcnow',

0 commit comments

Comments
 (0)