def Create(email_address=None, private_key_path=None, oauth_url=None):
if email_address:
from google.appengine.api.app_identity import app_identity_keybased_stub
logging.debug('Using the KeyBasedAppIdentityServiceStub.')
return app_identity_keybased_stub.KeyBasedAppIdentityServiceStub(
email_address=email_address,
private_key_path=private_key_path,
oauth_url=oauth_url)
elif sys.version_info >= (2, 6):
import six
if six._importer not in sys.meta_path:
sys.meta_path.append(six._importer)
from oauth2client import client
from google.appengine.api.app_identity import app_identity_defaultcredentialsbased_stub as ai_stub
try:
dc = ai_stub.DefaultCredentialsBasedAppIdentityServiceStub()
logging.debug('Successfully loaded Application Default Credentials.')
return dc
except client.ApplicationDefaultCredentialsError, error:
if not str(error).startswith('The Application Default Credentials '
'are not available.'):
logging.warning('An exception has been encountered when attempting '
'to use Application Default Credentials: %s'
'. Falling back on dummy AppIdentityServiceStub.',
str(error))
return AppIdentityServiceStub()
else:
logging.debug('Running under Python 2.5 uses dummy '
'AppIdentityServiceStub.')
return AppIdentityServiceStub()
app_identity_stub.py 文件源码
python
阅读 18
收藏 0
点赞 0
评论 0
评论列表
文章目录