谷歌云终端:身份验证问题(错误403)
我试图连接到运行的AppEngine应用程序我的谷歌云端点API:谷歌云终端:身份验证问题(错误403)
@endpoints.api(name='helloworldendpoints', allowed_client_ids=["1234", "12345"], version='v1', auth_level=endpoints.AUTH_LEVEL.REQUIRED)
class HelloWorldApi(remote.Service):
...
的API请求如下:
scopes = ["https://www.googleapis.com/auth/userinfo.email"]
credentials = ServiceAccountCredentials.from_json_keyfile_name("CloudEndpointsClient.json", scopes)
from httplib2 import Http
http_auth = credentials.authorize(Http())
from apiclient.discovery import build
api_root = 'https://myapp.appspot.com/_ah/api'
api = 'helloworldendpoints'
version = 'v1'
discovery_url = '%s/discovery/v1/apis/%s/%s/rest' % (api_root, api, version)
service = build(api, version, discoveryServiceUrl=discovery_url)
response = service.myFunction(myparameter = "123456").execute(http=http_auth)#
print response
如果我删除身份验证要求,这些请求可以很好地工作。 我知道验证是有效的,因为如果验证后错误发生变化。
我得到的错误信息是:
googleapiclient.errors.HttpError: https://my-app.appspot.com/_ah/api/helloworldendpoints/v1/obtainScoreFromEmail?myparameter=1234&alt=json returned "Access Not Configured. has not been used in project 123456789 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/helloworldendpoints/overview?project=123456789 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.">
,我不能让我的谷歌云项目的API,因为API不存在。
我发现工作是一个黑客周围。我在同一个项目上使用了一个用户身份验证(而不是服务器),它使用了相同的API(https://cloud.google.com/endpoints/docs/frameworks/python/access_from_python)。
我切换回我的初始服务器验证。它开始工作的方法。
当你知道该项目不存在,你为什么不创建一个? – Rajat
该项目确实存在。什么不是API服务启用。 – Luka
好的,在“Google Console> Library”中,您可以继续并启用您打算使用的api。你无法找到哪个特定的API – Rajat