8000 python-docs-samples/iap at imagen-customization · katiemn/python-docs-samples · GitHub
[go: up one dir, main page]

Skip to content
< 8000 script type="application/json" data-target="react-app.embeddedData">{"payload":{"allShortcutsEnabled":false,"path":"iap","repo":{"id":834236671,"defaultBranch":"main","name":"python-docs-samples","ownerLogin":"katiemn","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2024-07-26T18:14:24.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/21978337?v=4","public":true,"private":false,"isOrgOwned":false},"currentUser":null,"refInfo":{"name":"imagen-customization","listCacheKey":"v0:1747764681.0","canEdit":false,"refType":"branch","currentOid":"bf3a623d76b5641d661254e6416a3081db26a78e"},"tree":{"items":[{"name":"app_engine_app","path":"iap/app_engine_app","contentType":"directory"},{"name":"README.md","path":"iap/README.md","contentType":"file"},{"name":"example_gce_backend.py","path":"iap/example_gce_backend.py","contentType":"file"},{"name":"example_startup_script.sh","path":"iap/example_startup_script.sh","contentType":"file"},{"name":"generate_self_signed_jwt.py","path":"iap/generate_self_signed_jwt.py","contentType":"file"},{"name":"iap_test.py","path":"iap/iap_test.py","contentType":"file"},{"name":"make_iap_request.py","path":"iap/make_iap_request.py","contentType":"file"},{"name":"requirements-test.txt","path":"iap/requirements-test.txt","contentType":"file"},{"name":"requirements.txt","path":"iap/requirements.txt","contentType":"file"},{"name":"validate_jwt.py","path":"iap/validate_jwt.py","contentType":"file"}],"templateDirectorySuggestionUrl":null,"readme":{"displayName":"README.md","richText":"\u003carticle class=\"markdown-body entry-content container-lg\" itemprop=\"text\"\u003e\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch1 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eIdentity-Aware Proxy Samples\u003c/h1\u003e\u003ca id=\"user-content-identity-aware-proxy-samples\" class=\"anchor\" aria-label=\"Permalink: Identity-Aware Proxy Samples\" href=\"#identity-aware-proxy-samples\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003e\u003ca href=\"https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples\u0026amp;page=editor\u0026amp;open_in_editor=iap/README.md\" rel=\"nofollow\"\u003e\u003cimg src=\"https://camo.githubusercontent.com/cf29981159f3fb8f7d5c5ce0a4a4ab3d2a8e500b782d2016717c3e4aa6124bc5/687474703a2f2f677374617469632e636f6d2f636c6f75647373682f696d616765732f6f70656e2d62746e2e706e67\" alt=\"Open in Cloud Shell\" data-canonical-src=\"http://gstatic.com/cloudssh/images/open-btn.png\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\u003cp dir=\"auto\"\u003eThese samples are used on the following documentation pages:\u003c/p\u003e\n\u003cblockquote\u003e\n\u003c/blockquote\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ca href=\"https://cloud.google.com/iap/docs/authentication-howto\" rel=\"nofollow\"\u003ehttps://cloud.google.com/iap/docs/authentication-howto\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://cloud.google.com/iap/docs/signed-headers-howto\" rel=\"nofollow\"\u003ehttps://cloud.google.com/iap/docs/signed-headers-howto\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eUsing make_iap_request\u003c/h2\u003e\u003ca id=\"user-content-using-make_iap_request\" class=\"anchor\" aria-label=\"Permalink: Using make_iap_request\" href=\"#using-make_iap_request\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eGoogle App Engine flexible environment\u003c/h3\u003e\u003ca id=\"user-content-google-app-engine-flexible-environment\" class=\"anchor\" aria-label=\"Permalink: Google App Engine flexible environment\" href=\"#google-app-engine-flexible-environment\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003col dir=\"auto\"\u003e\n\u003cli\u003eAdd the contents of this directory's \u003ccode\u003erequirements.txt\u003c/code\u003e file to the one\ninside your application.\u003c/li\u003e\n\u003cli\u003eCopy \u003ccode\u003emake_iap_request.py\u003c/code\u003e into your application.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eGoogle App Engine standard environment\u003c/h3\u003e\u003ca id=\"user-content-google-app-engine-standard-environment\" class=\"anchor\" aria-label=\"Permalink: Google App Engine standard environment\" href=\"#google-app-engine-standard-environment\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003col dir=\"auto\"\u003e\n\u003cli\u003eFollow the instructions\nin\n\u003ca href=\"https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27#installing_a_third-party_library\" rel=\"nofollow\"\u003eInstalling a third-party library\u003c/a\u003e to\ninstall the \u003ccode\u003egoogle-auth\u003c/code\u003e and \u003ccode\u003erequests\u003c/code\u003e libraries into your application.\u003c/li\u003e\n\u003cli\u003eCopy \u003ccode\u003emake_iap_request.py\u003c/code\u003e into the same folder as app.yaml .\u003c/li\u003e\n\u003c/ol\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eGoogle Compute Engine or Google Kubernetes Engine\u003c/h3\u003e\u003ca id=\"user-content-google-compute-engine-or-google-kubernetes-engine\" class=\"anchor\" aria-label=\"Permalink: Google Compute Engine or Google Kubernetes Engine\" href=\"#google-compute-engine-or-google-kubernetes-engine\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003col dir=\"auto\"\u003e\n\u003cli\u003e\u003ca href=\"https://console.cloud.google.com/flows/enableapi?apiid=iam.googleapis.com\u0026amp;showconfirmation=true\" rel=\"nofollow\"\u003eClick here\u003c/a\u003e to visit Google Cloud Platform Console and enable the IAM API on your project.\u003c/li\u003e\n\u003cli\u003eCreate a VM with the IAM scope:\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"gcloud compute instances create INSTANCE_NAME\n--scopes=https://www.googleapis.com/auth/iam\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003egcloud compute instances create INSTANCE_NAME\n--scopes=https://www.googleapis.com/auth/iam\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003c/li\u003e\n\u003cli\u003eGive your VM's default service account the \u003ccode\u003eService Account Actor\u003c/code\u003e role:\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"gcloud projects add-iam-policy-binding PROJECT_ID\n--role=roles/iam.serviceAccountActor\n--member=serviceAccount:SERVICE_ACCOUNT\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003egcloud projects add-iam-policy-binding PROJECT_ID\n--role=roles/iam.serviceAccountActor\n--member=serviceAccount:SERVICE_ACCOUNT\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003c/li\u003e\n\u003cli\u003eInstall the libraries listed in \u003ccode\u003erequirements.txt\u003c/code\u003e, e.g. by running:\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"virtualenv/bin/pip install -r requirements.txt\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003evirtualenv/bin/pip install -r requirements.txt\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003c/li\u003e\n\u003cli\u003eCopy \u003ccode\u003emake_iap_request.py\u003c/code\u003e into your application.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eUsing a downloaded service account private key\u003c/h3\u003e\u003ca id=\"user-content-using-a-downloaded-service-account-private-key\" class=\"anchor\" aria-label=\"Permalink: Using a downloaded service account private key\" href=\"#using-a-downloaded-service-account-private-key\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003col dir=\"auto\"\u003e\n\u003cli\u003eCreate a service account and download its private key.\nSee \u003ca href=\"https://cloud.google.com/iam/docs/creating-managing-service-account-keys\" rel=\"nofollow\"\u003ehttps://cloud.google.com/iam/docs/creating-managing-service-account-keys\u003c/a\u003e\nfor more information on how to do this.\u003c/li\u003e\n\u003cli\u003eSet the environment variable \u003ccode\u003eGOOGLE_APPLICATION_CREDENTIALS\u003c/code\u003e to the path\nto your service account's \u003ccode\u003e.json\u003c/code\u003e file.\u003c/li\u003e\n\u003cli\u003eInstall the libraries listed in \u003ccode\u003erequirements.txt\u003c/code\u003e, e.g. by running:\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"virtualenv/bin/pip install -r requirements.txt\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003evirtualenv/bin/pip install -r requirements.txt\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003c/li\u003e\n\u003cli\u003eCopy \u003ccode\u003emake_iap_request.py\u003c/code\u003e into your application.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp dir=\"auto\"\u003eIf you prefer to manage service account credentials manually, this method can\nalso be used in the App Engine flexible environment, Compute Engine, and\nKubernetes Engine. Note that this may be less secure, as anyone who obtains the\nservice account private key can impersonate that account!\u003c/p\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eUsing validate_jwt\u003c/h2\u003e\u003ca id=\"user-content-using-validate_jwt\" class=\"anchor\" aria-label=\"Permalink: Using validate_jwt\" href=\"#using-validate_jwt\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003col dir=\"auto\"\u003e\n\u003cli\u003eInstall the libraries listed in \u003ccode\u003erequirements.txt\u003c/code\u003e, e.g. by running:\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"virtualenv/bin/pip install -r requirements.txt\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003evirtualenv/bin/pip install -r requirements.txt\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003c/li\u003e\n\u003cli\u003eCopy \u003ccode\u003evalidate_jwt.py\u003c/code\u003e into your application.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eUsing generate_self_signed_jwt\u003c/h2\u003e\u003ca id=\"user-content-using-generate_self_signed_jwt\" class=\"anchor\" aria-label=\"Permalink: Using generate_self_signed_jwt\" href=\"#using-generate_self_signed_jwt\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eSelf-signed JWT with IAM Credentials API\u003c/h3\u003e\u003ca id=\"user-content-self-signed-jwt-with-iam-credentials-api\" class=\"anchor\" aria-label=\"Permalink: Self-signed JWT with IAM Credentials API\" href=\"#self-signed-jwt-with-iam-credentials-api\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eEnsure that you are in the correct working directory: (/python-docs-samples/iap):\u003c/p\u003e\n\u003col dir=\"auto\"\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003eInstall the libraries listed in \u003ccode\u003e/python-docs-samples/iap/requirements.txt\u003c/code\u003e, e.g. by running:\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\" virtualenv/bin/pip install -r requirements.txt\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003e virtualenv/bin/pip install -r requirements.txt\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003eCall \u003ccode\u003esign_jwt\u003c/code\u003e in the python file. This example would create a JWT for the service account \u003ca href=\"mailto:email@gmail.com\"\u003eemail@gmail.com\u003c/a\u003e to access the IAP protected application hosted at \u003ca href=\"https://example.com\" rel=\"nofollow\"\u003ehttps://example.com\u003c/a\u003e.\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\" sign_jwt(\u0026quot;email@gmail.com\u0026quot;, \u0026quot;https://example.com\u0026quot;)\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003e sign_jwt(\"email@gmail.com\", \"https://example.com\")\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003eUse the result of the call to access your IAP protected resource programmatically:\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\" curl --verbose --header 'Authorization: Bearer SIGNED_JWT' \u0026quot;https://example.com\u0026quot;\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003e curl --verbose --header 'Authorization: Bearer SIGNED_JWT' \"https://example.com\"\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003c/li\u003e\n\u003c/ol\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eSelf-signed JWT with local key file\u003c/h3\u003e\u003ca id=\"user-content-self-signed-jwt-with-local-key-file\" class=\"anchor\" aria-label=\"Permalink: Self-signed JWT with local key file\" href=\"#self-signed-jwt-with-local-key-file\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003col dir=\"auto\"\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003eInstall the libraries listed in \u003ccode\u003e/python-docs-samples/iap/requirements.txt\u003c/code\u003e, e.g. by running:\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\" virtualenv/bin/pip install -r requirements.txt\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003e virtualenv/bin/pip install -r requirements.txt\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003eCreate a service account and download its private key.\nSee \u003ca href=\"https://cloud.google.com/iam/docs/creating-managing-service-account-keys\" rel=\"nofollow\"\u003ehttps://cloud.google.com/iam/docs/creating-managing-service-account-keys\u003c/a\u003e\nfor more information on how to do this.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003eCall \u003ccode\u003esign_jwt_with_local_credentials_file\u003c/code\u003e, using the downloaded local credentials\nfor the service account.\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\" sign_jwt_with_local_credentials_file(\u0026quot;path/to/key/file.json\u0026quot;, \u0026quot;https://example.com\u0026quot;)\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003e sign_jwt_with_local_credentials_file(\"path/to/key/file.json\", \"https://example.com\")\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003eUse the result of the call to access your IAP protected resource programmatically:\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\" curl --verbose --header 'Authorization: Bearer SIGNED_JWT' \u0026quot;https://example.com\u0026quot;\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003e curl --verbose --header 'Authorization: Bearer SIGNED_JWT' \"https://example.com\"\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003c/li\u003e\n\u003c/ol\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eRunning Tests\u003c/h2\u003e\u003ca id=\"user-content-running-tests\" class=\"anchor\" aria-label=\"Permalink: Running Tests\" href=\"#running-tests\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003col dir=\"auto\"\u003e\n\u003cli\u003eDeploy \u003ccode\u003eapp_engine_app\u003c/code\u003e to a project.\u003c/li\u003e\n\u003cli\u003eEnable Identity-Aware Proxy on that project's App Engine app.\u003c/li\u003e\n\u003cli\u003eAdd the service account you'll be running the test as to the\nIdentity-Aware Proxy access list for the project.\u003c/li\u003e\n\u003cli\u003eUpdate iap_test.py with the hostname for your project.\u003c/li\u003e\n\u003cli\u003eRun the command: \u003ccode\u003eGOOGLE_CLOUD_PROJECT=project-id pytest iap_test.py\u003c/code\u003e\u003c/li\u003e\n\u003c/ol\u003e\n\u003c/article\u003e","errorMessage":null,"headerInfo":{"toc":[{"level":1,"text":"Identity-Aware Proxy Samples","anchor":"identity-aware-proxy-samples","htmlText":"Identity-Aware Proxy Samples"},{"level":2,"text":"Using make_iap_request","anchor":"using-make_iap_request","htmlText":"Using make_iap_request"},{"level":3,"text":"Google App Engine flexible environment","anchor":"google-app-engine-flexible-environment","htmlText":"Google App Engine flexible environment"},{"level":3,"text":"Google App Engine standard environment","anchor":"google-app-engine-standard-environment","htmlText":"Google App Engine standard environment"},{"level":3,"text":"Google Compute Engine or Google Kubernetes Engine","anchor":"google-compute-engine-or-google-kubernetes-engine","htmlText":"Google Compute Engine or Google Kubernetes Engine"},{"level":3,"text":"Using a downloaded service account private key","anchor":"using-a-downloaded-service-account-private-key","htmlText":"Using a downloaded service account private key"},{"level":2,"text":"Using validate_jwt","anchor":"using-validate_jwt","htmlText":"Using validate_jwt"},{"level":2,"text":"Using generate_self_signed_jwt","anchor":"using-generate_self_signed_jwt","htmlText":"Using generate_self_signed_jwt"},{"level":3,"text":"Self-signed JWT with IAM Credentials API","anchor":"self-signed-jwt-with-iam-credentials-api","htmlText":"Self-signed JWT with IAM Credentials API"},{"level":3,"text":"Self-signed JWT with local key file","anchor":"self-signed-jwt-with-local-key-file","htmlText":"Self-signed JWT with local key file"},{"level":2,"text":"Running Tests","anchor":"running-tests","htmlText":"Running Tests"}],"siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fkatiemn%2Fpython-docs-samples%2Ftree%2Fimagen-customization%2Fiap"}},"totalCount":10,"showBranchInfobar":true},"fileTree":{"":{"items":[{"name":".github","path":".github","contentType":"directory"},{"name":".kokoro","path":".kokoro","contentType":"directory"},{"name":"alloydb","path":"alloydb","contentType":"directory"},{"name":"aml-ai","path":"aml-ai","contentType":"directory"},{"name":"appengine","path":"appengine","contentType":"directory"},{"name":"asset","path":"asset","contentType":"directory"},{"name":"auth","path":"auth","contentType":"directory"},{"name":"automl","path":"automl","contentType":"directory"},{"name":"batch","path":"batch","contentType":"directory"},{"name":"bigquery-connection","path":"bigquery-connection","contentType":"directory"},{"name":"bigquery-datatransfer","path":"bigquery-datatransfer","contentType":"directory"},{"name":"bigquery-migration","path":"bigquery-migration","contentType":"directory"},{"name":"bigquery-reservation","path":"bigquery-reservation","contentType":"directory"},{"name":"bigquery","path":"bigquery","contentType":"directory"},{"name":"bigquery_storage","path":"bigquery_storage","contentType":"directory"},{"name":"billing","path":"billing","contentType":"directory"},{"name":"blog","path":"blog","contentType":"directory"},{"name":"cdn","path":"cdn","contentType":"directory"},{"name":"cloud-media-livestream","path":"cloud-media-livestream","contentType":"directory"},{"name":"cloud-sql","path":"cloud-sql","contentType":"directory"},{"name":"cloud_scheduler","path":"cloud_scheduler","contentType":"directory"},{"name":"cloud_tasks","path":"cloud_tasks","contentType":"directory"},{"name":"cloudbuild","path":"cloudbuild","contentType":"directory"},{"name":"composer","path":"composer","contentType":"directory"},{"name":"compute","path":"compute","contentType":"directory"},{"name":"contact-center-insights","path":"contact-center-insights","contentType":"directory"},{"name":"container","path":"container","contentType":"directory"},{"name":"containeranalysis","path":"containeranalysis","contentType":"directory"},{"name":"contentwarehouse","path":"contentwarehouse","contentType":"directory"},{"name":"datacatalog","path":"datacatalog","contentType":"directory"},{"name":"dataflow","path":"dataflow","contentType":"directory"},{"name":"datalabeling","path":"datalabeling","contentType":"directory"},{"name":"dataplex","path":"dataplex","contentType":"directory"},{"name":"dataproc","path":"dataproc","contentType":"directory"},{"name":"datastore","path":"datastore","contentType":"directory"},{"name":"dialogflow-cx","path":"dialogflow-cx","contentType":"directory"},{"name":"dialogflow","path":"dialogflow","contentType":"directory"},{"name":"discoveryengine","path":"discoveryengine","contentType":"directory"},{"name":"dlp","path":"dlp","contentType":"directory"},{"name":"documentai","path":"documentai","contentType":"directory"},{"name":"endpoints","path":"endpoints","contentType":"directory"},{"name":"enterpriseknowledgegraph","path":"enterpriseknowledgegraph","contentType":"directory"},{"name":"error_reporting","path":"error_reporting","contentType":"directory"},{"name":"eventarc","path":"eventarc","contentType":"directory"},{"name":"firestore","path":"firestore","contentType":"directory"},{"name":"functions","path":"functions","contentType":"directory"},{"name":"gemma2","path":"gemma2","contentType":"directory"},{"name":"genai","path":"genai","contentType":"directory"},{"name":"generative_ai","path":"generative_ai","contentType":"directory"},{"name":"healthcare","path":"healthcare","contentType":"directory"},{"name":"iam","path":"iam","contentType":"directory"},{"name":"iap","path":"iap","contentType":"directory"},{"name":"iot","path":"iot","contentType":"directory"},{"name":"jobs","path":"jobs","contentType":"directory"},{"name":"kms","path":"kms","contentType":"directory"},{"name":"kubernetes_engine","path":"kubernetes_engine","contentType":"directory"},{"name":"language","path":"language","contentType":"directory"},{"name":"logging","path":"logging","contentType":"directory"},{"name":"managedkafka","path":"managedkafka","contentType":"directory"},{"name":"media-translation","path":"media-translation","contentType":"directory"},{"name":"media","path":"media","contentType":"directory"},{"name":"media_cdn","path":"media_cdn","contentType":"directory"},{"name":"memorystore","path":"memorystore","contentType":"directory"},{"name":"model_armor","path":"model_armor","contentType":"directory"},{"name":"model_garden","path":"model_garden","contentType":"directory"},{"name":"monitoring","path":"monitoring","contentType":"directory"},{"name":"notebooks","path":"notebooks","contentType":"directory"},{"name":"optimization","path":"optimization","contentType":"directory"},{"name":"parametermanager","path":"parametermanager","contentType":"directory"},{"name":"people-and-planet-ai","path":"people-and-planet-ai","contentType":"directory"},{"name":"practice-folder","path":"practice-folder","contentType":"directory"},{"name":"privateca","path":"privateca","contentType":"directory"},{"name":"profiler","path":"profiler","contentType":"directory"},{"name":"pubsub","path":"pubsub","contentType":"directory"},{"name":"pubsublite","path":"pubsublite","contentType":"directory"},{"name":"recaptcha_enterprise","path":"recaptcha_enterprise","contentType":"directory"},{"name":"retail","path":"retail","contentType":"directory"},{"name":"run","path":"run","contentType":"directory"},{"name":"scripts","path":"scripts","contentType":"directory"},{"name":"secretmanager","path":"secretmanager","contentType":"directory"},{"name":"securitycenter","path":"securitycenter","contentType":"directory"},{"name":"service_extensions","path":"service_extensions","contentType":"directory"},{"name":"servicedirectory","path":"servicedirectory","contentType":"directory"},{"name":"spanner","path":"spanner","contentType":"directory"},{"name":"speech","path":"speech","contentType":"directory"},{"name":"storage","path":"storage","contentType":"directory"},{"name":"storagecontrol","path":"storagecontrol","contentType":"directory"},{"name":"storagetransfer","path":"storagetransfer 374D ","contentType":"directory"},{"name":"tables","path":"tables","contentType":"directory"},{"name":"talent","path":"talent","contentType":"directory"},{"name":"testing","path":"testing","contentType":"directory"},{"name":"texttospeech","path":"texttospeech","contentType":"directory"},{"name":"tpu","path":"tpu","contentType":"directory"},{"name":"trace","path":"trace","contentType":"directory"},{"name":"translate","path":"translate","contentType":"directory"},{"name":"video","path":"video","contentType":"directory"},{"name":"videointelligence","path":"videointelligence","contentType":"directory"},{"name":"vision","path":"vision","contentType":"directory"},{"name":"vmwareengine","path":"vmwareengine","contentType":"directory"},{"name":"webrisk","path":"webrisk","contentType":"directory"},{"name":"workflows","path":"workflows","contentType":"directory"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".repo-metadata.json","path":".repo-metadata.json","contentType":"file"},{"name":".trampolinerc","path":".trampolinerc","contentType":"file"},{"name":".trampolinerc_tmpl","path":".trampolinerc_tmpl","contentType":"file"},{"name":"AUTHORING_GUIDE.md","path":"AUTHORING_GUIDE.md","contentType":"file"},{"name":"CODE_OF_CONDUCT.md","path":"CODE_OF_CONDUCT.md","contentType":"file"},{"name":"CONTRIBUTING.md","path":"CONTRIBUTING.md","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"MAC_SETUP.md","path":"MAC_SETUP.md","contentType":"file"},{"name":"Makefile","path":"Makefile","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"SECURITY.md","path":"SECURITY.md","contentType":"file"},{"name":"favicon.ico","path":"favicon.ico","contentType":"file"},{"name":"noxfile-template.py","path":"noxfile-template.py","contentType":"file"},{"name":"noxfile_config.py","path":"noxfile_config.py","contentType":"file"},{"name":"owlbot.py","path":"owlbot.py","contentType":"file"},{"name":"pytest.ini","path":"pytest.ini","contentType":"file"},{"name":"renovate.json","path":"renovate.json","contentType":"file"}],"totalCount":119}},"fileTreeProcessingTime":4.52405,"foldersToFetch":[],"treeExpanded":true,"symbolsExpanded":false,"csrf_tokens":{"/katiemn/python-docs-samples/branches":{"post":"NU7sseWZulcZt8e08FqZWGy0iTQDV9ubHA9p6E1CMJXGmBNAoAFZe1YSIwlmzHp4Ub4e-m_6cyCk88xqw3iICw"},"/katiemn/python-docs-samples/branches/fetch_and_merge/imagen-customization":{"post":"O2RjKF-_C9AzoH90pUnSJYdLAuVo11ynp7gqakxUWRM3Whuq-pHVwQmWO__L42wy28r4ZclhQ1faY0JwqVKZEw"},"/katiemn/python-docs-samples/branches/fetch_and_merge/imagen-customization?discard_changes=true":{"post":"E6g0_5wzycAAJ5sUT5doC1weisPQs-r7zCK3K_nXCA4flkx9OR0X0ToR358hPdYcAJ9wQ3EF9Qux-d8xHNHIDg"}}},"title":"python-docs-samples/iap at imagen-customization · katiemn/python-docs-samples","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-7d7eb7c71814.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-1ae9fa256942.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true,"github_models_repo_integration":false}}}
0