{ "info": { "author": "Jez Humble", "author_email": "humble@google.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# A small class that helps with authentication and CORS for HTTP-triggered cloud functions written in Python and hosted on GCP\n\n_Please note: This is not an officially supported Google product._\n\nIf you are using OAuth to authenticate to a [Cloud Function written in Python](https://cloud.google.com/functions/docs/concepts/python-runtime) and hosted on GCP, and your client is running in a browser, this is for you. If not, you probably won't find this useful.\n\nThis class does three things:\n\n* Responds correctly and configurably to the HTTP OPTIONS method used by browsers to do pre-flight checks as part of CORS\n* Retrieves an OAuth2 token supplied in the `Authorization` HTTP header, validates it, and then fetches the information encoded by the token\n* Gives you back either a valid token, or a response to send back to the user in case a valid token can't be found\n\n## Installation\n\nYou can install the latest version of this package using pip:\n\n`python3 -m pip install --user gcloud-flask-oauth-cors`\n\nIt's hosted on pypi: https://pypi.org/project/gcloud-flask-oauth-cors/\n\n## Use\n\nIf you don't have one, [create an OAuth client ID](https://developers.google.com/identity/protocols/OAuth2WebServer) and [pass it as an environment variable](https://cloud.google.com/functions/docs/env-var) to your cloud function. Then, you can use the following: \n\n```\nimport gcloud_flask_oauth_cors as oauth\n\ndef my_function_name(request):\n auth = oauth.Auth(os.getenv(\"OAUTH_CLIENT_ID\"))\n id_info = auth.get_id_info(request)\n if id_info is None:\n # If we were called with the HTTP OPTIONS method, this will return the relevant CORS headers.\n # If another HTTP method was used and we can't authenticate, this will return a 401 (Unauthorized)\n return auth.get_response()\n\n # Do something with the id_info, for example:\n print(id_info[\"sub\"])\n```\n\nOn the client side, you can use [Google Sign-in](https://developers.google.com/identity/sign-in/web/). Make sure you pass your `id_token` in any requests like this:\n\n```\nlet xhr = new XMLHttpRequest();\nxhr.setRequestHeader(\"Authorization\", \"Bearer \" + id_token);\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/googlecloudplatform/flask-oauth-cors", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "gcloud-flask-oauth-cors", "package_url": "https://pypi.org/project/gcloud-flask-oauth-cors/", "platform": "", "project_url": "https://pypi.org/project/gcloud-flask-oauth-cors/", "project_urls": { "Homepage": "https://github.com/googlecloudplatform/flask-oauth-cors" }, "release_url": "https://pypi.org/project/gcloud-flask-oauth-cors/0.1.1/", "requires_dist": [ "google-api-python-client", "google-auth" ], "requires_python": "", "summary": "A tiny utility to authenticate requests using GCP OAuth and send CORS headers in Flask", "version": "0.1.1" }, "last_serial": 5227567, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "b86ba1661be9302a0834bdb4b533bdc3", "sha256": "54244aae0cd03229801c74e993223949eb053373b0f53849f00b110408be43e2" }, "downloads": -1, "filename": "gcloud_flask_oauth_cors-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "b86ba1661be9302a0834bdb4b533bdc3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8253, "upload_time": "2019-05-05T05:37:57", "url": "https://files.pythonhosted.org/packages/51/6a/9dc480642386f4f25eeeb6147cda503a6572e0825cffe64168a336747b34/gcloud_flask_oauth_cors-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ce1256600c5e732eafce75012816456e", "sha256": "afa1a18c5cfc2eedc3e438bc7f48aece600f34f4adae922182ea59094c3a55b7" }, "downloads": -1, "filename": "gcloud-flask-oauth-cors-0.1.1.tar.gz", "has_sig": false, "md5_digest": "ce1256600c5e732eafce75012816456e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3169, "upload_time": "2019-05-05T05:37:58", "url": "https://files.pythonhosted.org/packages/61/19/2d7f3d5c079bc4ad80a20f59ee580f213c17a55d3d9dd1c53a31caa99c1e/gcloud-flask-oauth-cors-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b86ba1661be9302a0834bdb4b533bdc3", "sha256": "54244aae0cd03229801c74e993223949eb053373b0f53849f00b110408be43e2" }, "downloads": -1, "filename": "gcloud_flask_oauth_cors-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "b86ba1661be9302a0834bdb4b533bdc3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8253, "upload_time": "2019-05-05T05:37:57", "url": "https://files.pythonhosted.org/packages/51/6a/9dc480642386f4f25eeeb6147cda503a6572e0825cffe64168a336747b34/gcloud_flask_oauth_cors-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ce1256600c5e732eafce75012816456e", "sha256": "afa1a18c5cfc2eedc3e438bc7f48aece600f34f4adae922182ea59094c3a55b7" }, "downloads": -1, "filename": "gcloud-flask-oauth-cors-0.1.1.tar.gz", "has_sig": false, "md5_digest": "ce1256600c5e732eafce75012816456e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3169, "upload_time": "2019-05-05T05:37:58", "url": "https://files.pythonhosted.org/packages/61/19/2d7f3d5c079bc4ad80a20f59ee580f213c17a55d3d9dd1c53a31caa99c1e/gcloud-flask-oauth-cors-0.1.1.tar.gz" } ] }