私はAppEngineのアプリとして実行されている私のGoogleクラウドエンドポイントAPIに接続しようとしている:Googleクラウドエンドポイント:認証の問題(エラー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が存在しないので、私は、私のGoogleクラウドプロジェクトでAPIを有効にすることはできません。
プロジェクトが存在しないことがわかっている場合、なぜそれを作成していないのですか? – Rajat
プロジェクトは存在します。有効にするAPIサービスはありません。 – Luka
「Google Console>ライブラリ」では、使用するAPIを有効にすることができます。どの特定のAPIが見つからないのですか – Rajat