|
23 | 23 |
|
24 | 24 |
|
25 | 25 | _request = requests.Request() |
26 | | - |
| 26 | +_scopes = [ |
| 27 | + 'https://www.googleapis.com/auth/firebase', |
| 28 | + 'https://www.googleapis.com/auth/userinfo.email' |
| 29 | +] |
27 | 30 |
|
28 | 31 | AccessTokenInfo = collections.namedtuple( |
29 | 32 | 'AccessTokenInfo', ['access_token', 'expiry']) |
@@ -67,7 +70,8 @@ def __init__(self, file_path): |
67 | 70 | '"type" field set to "{1}".'.format(file_path, self._CREDENTIAL_TYPE)) |
68 | 71 | self._project_id = json_data.get('project_id') |
69 | 72 | try: |
70 | | - self._g_credential = service_account.Credentials.from_service_account_info(json_data) |
| 73 | + self._g_credential = service_account.Credentials.from_service_account_info( |
| 74 | + json_data, scopes=_scopes) |
71 | 75 | except ValueError as error: |
72 | 76 | raise ValueError('Failed to initialize a certificate credential from file "{0}". ' |
73 | 77 | 'Caused by: "{1}"'.format(file_path, error)) |
@@ -112,7 +116,7 @@ def __init__(self): |
112 | 116 | credentials cannot be initialized in the current environment. |
113 | 117 | """ |
114 | 118 | super(ApplicationDefault, self).__init__() |
115 | | - self._g_credential, self._project_id = google.auth.default() |
| 119 | + self._g_credential, self._project_id = google.auth.default(scopes=_scopes) |
116 | 120 |
|
117 | 121 | def get_access_token(self): |
118 | 122 | """Fetches a Google OAuth2 access token using this application default credential. |
@@ -166,7 +170,7 @@ def __init__(self, file_path): |
166 | 170 | self._g_credential = credentials.Credentials( |
167 | 171 | token=None, refresh_token=refresh_token, |
168 | 172 | token_uri='https://accounts.google.com/o/oauth2/token', |
169 | | - client_id=client_id, client_secret=client_secret) |
| 173 | + client_id=client_id, client_secret=client_secret, scopes=_scopes) |
170 | 174 |
|
171 | 175 | @property |
172 | 176 | def client_id(self): |
|
0 commit comments