0

我試圖連接到運行的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不存在。

+0

當你知道該項目不存在,你爲什麼不創建一個? – Rajat

+0

該項目確實存在。什麼不是API服務啓用。 – Luka

+0

好的,在「Google Console> Library」中,您可以繼續並啓用您打算使用的api。你無法找到哪個特定的API – Rajat

回答

相關問題