Title: API management for multiple APIs only work for one. · Issue #188 · cloudendpoints/endpoints-python · GitHub
Open Graph Title: API management for multiple APIs only work for one. · Issue #188 · cloudendpoints/endpoints-python
X Title: API management for multiple APIs only work for one. · Issue #188 · cloudendpoints/endpoints-python
Description: I struggled to get multiple APIs working correctly for days. After I deployed the service using the steps below, although both api require api key, the problems are: I can call one of them without providing api key while the other does r...
Open Graph Description: I struggled to get multiple APIs working correctly for days. After I deployed the service using the steps below, although both api require api key, the problems are: I can call one of them without ...
X Description: I struggled to get multiple APIs working correctly for days. After I deployed the service using the steps below, although both api require api key, the problems are: I can call one of them without ...
Opengraph URL: https://github.com/cloudendpoints/endpoints-python/issues/188
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"API management for multiple APIs only work for one.","articleBody":"I struggled to get multiple APIs working correctly for days.\r\nAfter I deployed the service using the steps below, although both api require api key, the problems are:\r\n1. **I can call one of them without providing api key while the other does require an api key.**\r\n2. Only one of the API are showing up in developer portal. Sometimes AuthedGreetingApi, sometimes GreetingApi.\r\n \r\nIs this a bug for cloud endpoints?\r\n\r\n```\r\npython lib/endpoints/endpointscfg.py get_openapi_spec main.GreetingApi main.AuthedGreetingApi --hostname inner-cinema-211407.appspot.com --x-google-api-name\r\n```\r\nthis generates `greetingv1openapi.json` and `authedgreetingv1openapi.json` \r\n\r\n\r\n```\r\ngcloud endpoints services deploy greetingv1openapi.json authedgreetingv1openapi.json \r\nresult: Service Configuration [2019-01-07r9] uploaded for service [inner-cinema-211407.appspot.com]\r\n```\r\nupdate the app.yaml as following:\r\n```\r\nenv_variables:\r\n # The following values are to be replaced by information from the output of\r\n # 'gcloud endpoints services deploy swagger.json' command.\r\n ENDPOINTS_SERVICE_NAME: inner-cinema-211407.appspot.com\r\n ENDPOINTS_SERVICE_VERSION: 2019-01-07r9\r\n```\r\ndeploy to GAE\r\n```\r\ngcloud app deploy --project=inner-cinema-211407\r\n```\r\nSource code:\r\n```python\r\n\r\n# [START messages]\r\nclass Greeting(messages.Message):\r\n \"\"\"Greeting that stores a message.\"\"\"\r\n message = messages.StringField(1)\r\n\r\n\r\nclass GreetingCollection(messages.Message):\r\n \"\"\"Collection of Greetings.\"\"\"\r\n items = messages.MessageField(Greeting, 1, repeated=True)\r\n\r\n\r\nSTORED_GREETINGS = GreetingCollection(items=[\r\n Greeting(message='hello world!'),\r\n Greeting(message='goodbye world!'),\r\n])\r\n\r\n\r\n# [END messages]\r\n\r\n\r\n# [START greeting_api]\r\n@endpoints.api(name='greeting', version='v1', api_key_required=True)\r\nclass GreetingApi(remote.Service):\r\n @endpoints.method(\r\n # This method does not take a request message.\r\n message_types.VoidMessage,\r\n # This method returns a GreetingCollection message.\r\n GreetingCollection,\r\n path='greetings',\r\n http_method='GET',\r\n name='greetings.list')\r\n def list_greetings(self, unused_request):\r\n return STORED_GREETINGS\r\n\r\n # ResourceContainers are used to encapsuate a request body and url\r\n # parameters. This one is used to represent the Greeting ID for the\r\n # greeting_get method.\r\n GET_RESOURCE = endpoints.ResourceContainer(\r\n # The request body should be empty.\r\n message_types.VoidMessage,\r\n # Accept one url parameter: and integer named 'id'\r\n id=messages.IntegerField(1, variant=messages.Variant.INT32))\r\n\r\n @endpoints.method(\r\n # Use the ResourceContainer defined above to accept an empty body\r\n # but an ID in the query string.\r\n GET_RESOURCE,\r\n # This method returns a Greeting message.\r\n Greeting,\r\n # The path defines the source of the URL parameter 'id'. If not\r\n # specified here, it would need to be in the query string.\r\n path='greetings/{id}',\r\n http_method='GET',\r\n name='greetings.get')\r\n def get_greeting(self, request):\r\n try:\r\n # request.id is used to access the URL parameter.\r\n return STORED_GREETINGS.items[request.id]\r\n except (IndexError, TypeError):\r\n raise endpoints.NotFoundException(\r\n 'Greeting {} not found'.format(request.id))\r\n\r\n # [END greeting_api]\r\n\r\n # [START multiply]\r\n # This ResourceContainer is similar to the one used for get_greeting, but\r\n # this one also contains a request body in the form of a Greeting message.\r\n MULTIPLY_RESOURCE = endpoints.ResourceContainer(\r\n Greeting,\r\n times=messages.IntegerField(2, variant=messages.Variant.INT32,\r\n required=True))\r\n\r\n @endpoints.method(\r\n # This method accepts a request body containing a Greeting message\r\n # and a URL parameter specifying how many times to multiply the\r\n # message.\r\n MULTIPLY_RESOURCE,\r\n # This method returns a Greeting message.\r\n Greeting,\r\n path='greetings/multiply/{times}',\r\n http_method='POST',\r\n name='greetings.multiply')\r\n def multiply_greeting(self, request):\r\n return Greeting(message=request.message * request.times)\r\n # [END multiply]\r\n\r\n\r\n# [START auth_config]\r\nWEB_CLIENT_ID = 'replace this with your web client application ID'\r\nANDROID_CLIENT_ID = 'replace this with your Android client ID'\r\nIOS_CLIENT_ID = 'replace this with your iOS client ID'\r\nANDROID_AUDIENCE = WEB_CLIENT_ID\r\nALLOWED_CLIENT_IDS = [\r\n WEB_CLIENT_ID, ANDROID_CLIENT_ID, IOS_CLIENT_ID,\r\n endpoints.API_EXPLORER_CLIENT_ID]\r\n\r\n\r\n# [END auth_config]\r\n\r\n\r\n# [START authed_greeting_api]\r\n@endpoints.api(\r\n name='authedgreeting',\r\n version='v1',\r\n # Only allowed configured Client IDs to access this API.\r\n allowed_client_ids=ALLOWED_CLIENT_IDS,\r\n # Only allow auth tokens with the given audience to access this API.\r\n audiences=[ANDROID_AUDIENCE],\r\n api_key_required=True,\r\n # Require auth tokens to have the following scopes to access this API.\r\n scopes=[endpoints.EMAIL_SCOPE])\r\nclass AuthedGreetingApi(remote.Service):\r\n @endpoints.method(\r\n message_types.VoidMessage,\r\n Greeting,\r\n path='greet',\r\n http_method='POST',\r\n name='greet')\r\n def greet(self, request):\r\n user = endpoints.get_current_user()\r\n user_name = user.email() if user else 'Anonymous'\r\n return Greeting(message='Hello, {}'.format(user_name))\r\n\r\n\r\n# [END authed_greeting_api]\r\n\r\n\r\n# [START api_server]\r\napi = endpoints.api_server([GreetingApi, AuthedGreetingApi])\r\n# [END api_server]\r\n```","author":{"url":"https://github.com/zjaml","@type":"Person","name":"zjaml"},"datePublished":"2019-01-07T14:40:40.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/188/endpoints-python/issues/188"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:78422107-43b4-a25a-f703-30dd8db29073 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9606:8E478:1094DE:186CAD:6A4DFBA8 |
| html-safe-nonce | 173b8181833017c5d9ab931c25f126fcd2e12128ff43f9b0f5e85b1f4e099e5a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NjA2OjhFNDc4OjEwOTRERToxODZDQUQ6NkE0REZCQTgiLCJ2aXNpdG9yX2lkIjoiNzEyMDY5NTk5MzQzNjA3Njk2OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 65212184894e54f3e5ccee8df00ff62ee9771c5f05de15f56778cdcf89364933 |
| hovercard-subject-tag | issue:396512567 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/cloudendpoints/endpoints-python/188/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2fb4c54f43ba49882fd7774e940e63f7de3d13f10121914dc3d887a0fe72a4e7/cloudendpoints/endpoints-python/issues/188 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2fb4c54f43ba49882fd7774e940e63f7de3d13f10121914dc3d887a0fe72a4e7/cloudendpoints/endpoints-python/issues/188 |
| og:image:alt | I struggled to get multiple APIs working correctly for days. After I deployed the service using the steps below, although both api require api key, the problems are: I can call one of them without ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zjaml |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5818716c93c6a2925b815402541a32814e43a7b1261c322b0c2df75224289566 |
| turbo-cache-control | no-preview |
| go-import | github.com/cloudendpoints/endpoints-python git https://github.com/cloudendpoints/endpoints-python.git |
| octolytics-dimension-user_id | 19231370 |
| octolytics-dimension-user_login | cloudendpoints |
| octolytics-dimension-repository_id | 65349604 |
| octolytics-dimension-repository_nwo | cloudendpoints/endpoints-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 65349604 |
| octolytics-dimension-repository_network_root_nwo | cloudendpoints/endpoints-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4314b1df11fa8a565684f3a72dc971e3785da365 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width