mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 12:21:35 +00:00
ensure get_admin_credentials only returns fresh creds
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
"""Authentication/Credentials general purpose and convenience methods."""
|
"""Authentication/Credentials general purpose and convenience methods."""
|
||||||
|
|
||||||
from . import oauth
|
import transport
|
||||||
from var import _FN_OAUTH2_TXT
|
from var import _FN_OAUTH2_TXT
|
||||||
from var import GC_OAUTH2_TXT
|
from var import GC_OAUTH2_TXT
|
||||||
from var import GC_Values
|
from var import GC_Values
|
||||||
|
from . import oauth
|
||||||
# TODO: Move logic that determines file name into this module. We should be able
|
# TODO: Move logic that determines file name into this module. We should be able
|
||||||
# to discover the file location without accessing a private member or waiting
|
# to discover the file location without accessing a private member or waiting
|
||||||
# for a global initialization.
|
# for a global initialization.
|
||||||
@@ -17,11 +17,14 @@ def get_admin_credentials_filename():
|
|||||||
# some custom name in it. Otherwise, just use the default name.
|
# some custom name in it. Otherwise, just use the default name.
|
||||||
if GC_Values[GC_OAUTH2_TXT]:
|
if GC_Values[GC_OAUTH2_TXT]:
|
||||||
return GC_Values[GC_OAUTH2_TXT]
|
return GC_Values[GC_OAUTH2_TXT]
|
||||||
else:
|
|
||||||
return DEFAULT_OAUTH_STORAGE_FILE
|
return DEFAULT_OAUTH_STORAGE_FILE
|
||||||
|
|
||||||
|
|
||||||
def get_admin_credentials():
|
def get_admin_credentials():
|
||||||
"""Gets oauth.Credentials that are authenticated as the domain's admin user."""
|
"""Gets oauth.Credentials that are authenticated as the domain's admin user."""
|
||||||
credential_file = get_admin_credentials_filename()
|
credential_file = get_admin_credentials_filename()
|
||||||
return oauth.Credentials.from_credentials_file(credential_file)
|
creds = oauth.Credentials.from_credentials_file(credential_file)
|
||||||
|
if creds.expired:
|
||||||
|
request = transport.create_request()
|
||||||
|
creds.refresh(request)
|
||||||
|
return creds
|
||||||
|
|||||||
@@ -7817,9 +7817,6 @@ def doCreateResoldCustomer():
|
|||||||
def _getValueFromOAuth(field, credentials=None):
|
def _getValueFromOAuth(field, credentials=None):
|
||||||
if not credentials:
|
if not credentials:
|
||||||
credentials = auth.get_admin_credentials()
|
credentials = auth.get_admin_credentials()
|
||||||
if credentials.expired:
|
|
||||||
request = transport.create_request()
|
|
||||||
credentials.refresh(request)
|
|
||||||
return credentials.get_token_value(field)
|
return credentials.get_token_value(field)
|
||||||
|
|
||||||
def doGetMemberInfo():
|
def doGetMemberInfo():
|
||||||
|
|||||||
Reference in New Issue
Block a user