def make_get_access_token_call(rpc, scopes, service_account_id=None):
 request = app_identity_service_pb.GetAccessTokenRequest()
 if (not scopes):
  raise InvalidScope('No scopes specified.')
 if isinstance(scopes, basestring):
  request.add_scope(scopes)
 else:
  for scope in scopes:
   request.add_scope(scope)
 if service_account_id:
  request.set_service_account_id(service_account_id)
 response = app_identity_service_pb.GetAccessTokenResponse()
 def get_access_token_result(rpc):
  'Check success, handle exceptions, and return converted RPC result.\n\n    This method waits for the RPC if it has not yet finished, and calls the\n    post-call hooks on the first invocation.\n\n    Args:\n      rpc: A UserRPC object.\n\n    Returns:\n      Pair, Access token (string) and expiration time (seconds since the epoch).\n    '
  assert (rpc.service == _APP_IDENTITY_SERVICE_NAME), repr(rpc.service)
  assert (rpc.method == _GET_ACCESS_TOKEN_METHOD_NAME), repr(rpc.method)
  try:
   rpc.check_success()
  except apiproxy_errors.ApplicationError as err:
   raise _to_app_identity_error(err)
  return (response.access_token(), response.expiration_time())
 rpc.make_call(_GET_ACCESS_TOKEN_METHOD_NAME, request, response, get_access_token_result)

def make_get_access_token_call ( rpc , scopes , service_account_id = None ) : request = app_identity_service_pb . GetAccessTokenRequest ( ) if ( not scopes ) : raise InvalidScope ( 'No scopes specified.' ) if isinstance ( scopes , basestring ) : request . add_scope ( scopes ) else : for scope in scopes : request . add_scope ( scope ) if service_account_id : request . set_service_account_id ( service_account_id ) response = app_identity_service_pb . GetAccessTokenResponse ( ) def get_access_token_result ( rpc ) : assert ( rpc . service == _APP_IDENTITY_SERVICE_NAME ) , repr ( rpc . service ) assert ( rpc . method == _GET_ACCESS_TOKEN_METHOD_NAME ) , repr ( rpc . method ) try : rpc . check_success ( ) except apiproxy_errors . ApplicationError as err : raise _to_app_identity_error ( err ) return ( response . access_token ( ) , response . expiration_time ( ) ) rpc . make_call ( _GET_ACCESS_TOKEN_METHOD_NAME , request , response , get_access_token_result )
oauth2 access token to act on behalf of the application .