Python 默认appengine服务帐户没有客户端id。为什么或?
我可以使用默认服务帐户Python 默认appengine服务帐户没有客户端id。为什么或?,python,google-app-engine,oauth,service-accounts,Python,Google App Engine,Oauth,Service Accounts,我可以使用默认服务帐户@appspot.gserviceaccount.com获取访问令牌并发出请求 接收appenine应用程序的oauth提供程序为get\u client\u id(SCOPE)接收“anonymous”。我使用这个范围=”https://www.googleapis.com/auth/userinfo.email“ 提出请求: access_token = app_identity.get_access_token(SCOPE)[0] response = url
@appspot.gserviceaccount.com
获取访问令牌并发出请求
接收appenine应用程序的oauth提供程序为get\u client\u id(SCOPE)
接收“anonymous
”。我使用这个范围=”https://www.googleapis.com/auth/userinfo.email“
提出请求:
access_token = app_identity.get_access_token(SCOPE)[0]
response = urlfetch.fetch(
"https://my-other.appspot.com/provider",
method=urlfetch.POST,
payload=...,
follow_redirects=False,
headers={"Content-Type": "application/json",
"Authorization": "Bearer " + access_token})
class ProviderHandler(webapp2.RequestHandler):
def post(self):
logging.info('app_id=' + self.request.headers['X-Appengine-Inbound-Appid'])
token_audience = oauth.get_client_id(SCOPE) # anonymous ??
处理请求:
access_token = app_identity.get_access_token(SCOPE)[0]
response = urlfetch.fetch(
"https://my-other.appspot.com/provider",
method=urlfetch.POST,
payload=...,
follow_redirects=False,
headers={"Content-Type": "application/json",
"Authorization": "Bearer " + access_token})
class ProviderHandler(webapp2.RequestHandler):
def post(self):
logging.info('app_id=' + self.request.headers['X-Appengine-Inbound-Appid'])
token_audience = oauth.get_client_id(SCOPE) # anonymous ??
创建新服务帐户时,请提供新私钥并使用:
credentials = ServiceAccountCredentials.from_json_keyfile_name(<json_file_name>, SCOPE)
acees_token = credentials.get_access_token().access_token
credentials=ServiceAccountCredentials.from_json_keyfile_name(,SCOPE)
acees\u token=凭据。获取\u访问\u token()。访问\u token
它工作正常。如果您是从App Engine拨打电话,为什么不使用应用程序默认凭据?我本来可以也将可以工作,但我尝试使用App_identity返回的默认凭据。问题:如果应用程序默认凭据由GOOGLE_Application_Credentials环境变量设置,app_identity是否会使用此默认凭据服务帐户?如果您是从app Engine呼叫,为什么不使用应用程序默认凭据?我本来可以也会工作,但我尝试使用app_identity返回的默认值。问题:如果应用程序默认凭据由GOOGLE\u Application\u Credentials环境变量设置,app\u identity是否会使用此默认凭据服务帐户?