Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Se você quiser exigir autenticação para acessar o back-end da API, é preciso ter os IDs de cliente necessários e fornecê-los ao back-end usando o argumento adequado do decorador da API.
Android
Para criar o ID do cliente do OAuth 2.0 para Android, é preciso ter uma impressão digital da chave de certificado. Se você usa o Android Studio, uma keystore e uma chave de depuração são criadas automaticamente. É possível usar essa chave para realizar testes. No entanto, é preciso usar uma de liberação para a produção.
A senha do keystore de depuração padrão é android e o alias de chave é androiddebugkey. O local padrão para Linux e macOS é ~/.android/debug.keystore.
Se você ainda não tiver uma, gere uma chave de depuração ou liberação para o aplicativo Android. Se você usa o Android Studio, uma chave de depuração no keystore de depuração é gerada automaticamente na primeira vez que você compila um projeto do Android.
Em uma janela de terminal do Linux ou macOS, é possível ter a impressão digital da chave usando keytool incluído com o SDK do Java da seguinte maneira:
A saída exibe uma impressão digital semelhante a esta:
DA:39:A3:EE:5E:6B:4B:0D:32:55:BF:EF:95:60:18:90:AF:D8:07:09
Copie e salve a impressão digital de chave que é exibida após executar o comando keytool anterior. É necessário fornecer a impressão digital para
gerar o ID do cliente Android no console Google Cloud .
No Google Cloud console, acesse a página Credenciais.
Na lista de projetos, selecione aquele que contém sua API.
Se esta é a primeira vez que você cria um ID do cliente neste projeto, use as subetapas para acessar a página de consentimento do OAuth. Caso contrário, pule para a próxima etapa.
Clique na Tela de consentimento do OAuth.
Digite um nome no campo Nome do aplicativo.
Preencha o restante dos campos conforme necessário.
Clique em Salvar.
Na lista suspensa Criar credenciais, selecione o ID do cliente do OAuth.
Selecione Android como o tipo de aplicativo.
Em Nome, insira um nome para o ID de cliente.
Em Impressão digital do certificado de inscrição, digite a impressão digital anterior.
Em Nome do pacote , insira o nome do pacote do aplicativo Android, conforme especificado no seu arquivo AndroidManifest.xml.
Clique em Criar.
Use o ID do cliente gerado no back-end da API e no aplicativo do cliente.
Cliente da Web
No Google Cloud console, acesse a página Credenciais.
Na lista de projetos, selecione aquele que contém sua API.
Se esta é a primeira vez que você cria um ID do cliente neste projeto, use as subetapas para acessar a página de consentimento do OAuth. Caso contrário, pule para a próxima etapa.
Clique na Tela de consentimento do OAuth.
Digite um nome no campo Nome do aplicativo.
Preencha o restante dos campos conforme necessário.
Clique em Salvar.
Na lista suspensa Criar credenciais, selecione o ID do cliente do OAuth.
Selecione Aplicativo da Web como o tipo de aplicativo.
Em Nome, insira um nome para o ID de cliente.
Em Origens JavaScript autorizadas, digite um dos itens a seguir:
https://YOUR_PROJECT_ID.appspot.com, substituindo YOUR_PROJECT_ID pelo código de projeto do App Engine, caso esteja implantando sua API de back-end no App Engine de produção.
Clique em Criar.
Use o ID do cliente gerado no back-end da API e no aplicativo do cliente.
A seguir
Para ver informações sobre como dar suporte à autenticação no seu aplicativo Android ou JavaScript, consulte:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-04 UTC."],[[["\u003cp\u003eTo secure your API backend, you must obtain and provide client IDs using the appropriate API decorator argument.\u003c/p\u003e\n"],["\u003cp\u003eFor Android applications, a signing-certificate fingerprint is required to create an OAuth 2.0 client ID, obtainable via the \u003ccode\u003ekeytool\u003c/code\u003e command.\u003c/p\u003e\n"],["\u003cp\u003eCreating an Android client ID involves selecting "Android" as the application type and providing the signing-certificate fingerprint and application package name in the Google Cloud console.\u003c/p\u003e\n"],["\u003cp\u003eCreating a web client ID requires selecting "Web application" as the application type, and specifying the authorized JavaScript origins, either for local testing or production deployment, in the Google Cloud console.\u003c/p\u003e\n"],["\u003cp\u003eThe generated client ID, whether for web or Android, is needed in both the API backend and the client application to permit access.\u003c/p\u003e\n"]]],[],null,["# Creating client IDs\n\nIf you want to require authentication to access your API backend, you must obtain\nthe required client IDs and supply them to the backend by using the proper API\n\ndecorator argument.\n\n### Android\n\n\nTo create the OAuth 2.0 Android client ID, you need to have a\ncertificate key fingerprint. If you use Android Studio, a debug keystore\nand a debug key are created automatically. You can use the debug key for\ntesting purposes, but you must use a release key for production.\n\n\nNote that the default debug keystore password is `android`, and\nthe key alias is `androiddebugkey`. The default location for Linux\nand macOS is `~/.android/debug.keystore`.\n| **Warning:** When you create a release key, don't use `android` as your release key or keystore password.\n\n1. If you don't already have one, generate a debug or release key for your Android application. If you use Android Studio, it automatically generates a debug key in the debug keystore the first time you build an Android project.\n2. In a Linux or macOS terminal window, you can get the fingerprint of the key by using the `keytool` included with the Java SDK as follows: \n\n ```python\n keytool -exportcert -alias androiddebugkey -keystore path-to-debug-or-production-keystore -list -v\n ```\n The output displays a fingerprint similar to the following: `DA:39:A3:EE:5E:6B:4B:0D:32:55:BF:EF:95:60:18:90:AF:D8:07:09`\n3. Copy and save the key fingerprint that is displayed after your run the preceding `keytool` command. You need to supply the fingerprint to generate the Android client ID in the Google Cloud console.\n4. In the Google Cloud console, go to the **Credentials** page.\n\n [Go to the Credentials page](https://console.cloud.google.com/apis/credentials)\n5. From the projects list, select the project containing your API.\n6. If this is your first time creating a client ID in this project, use the sub-steps to go to the **OAuth consent** page; otherwise, skip to the next step.\n 1. Click **OAuth consent screen**.\n 2. Enter a name in the **Application name** field.\n 3. Fill out the rest of the fields as needed.\n 4. Click **Save**.\n7. In the **Create credentials** drop-down list, select **OAuth client ID**.\n8. Select **Android** as the application type.\n9. In **Name**, enter a name for your client ID.\n10. In **Signing-certificate fingerprint**, enter the fingerprint you obtained previously.\n11. In **Package name** , enter the Android application package name, as specified in your `AndroidManifest.xml` file.\n12. Click **Create** .\n\n\n You use the generated client ID in your API backend and in your client\n application.\n\n### Web client\n\n1. In the Google Cloud console, go to the **Credentials** page.\n\n [Go to the Credentials page](https://console.cloud.google.com/apis/credentials)\n2. From the projects list, select the project containing your API.\n3. If this is your first time creating a client ID in this project, use the sub-steps to go to the **OAuth consent** page; otherwise, skip to the next step.\n 1. Click **OAuth consent screen**.\n 2. Enter a name in the **Application name** field.\n 3. Fill out the rest of the fields as needed.\n 4. Click **Save**.\n4. In the **Create credentials** drop-down list, select **OAuth client ID**.\n5. Select **Web application** as the application type.\n6. In **Name**, enter a name for your client ID.\n7. In **Authorized JavaScript origins** , enter one of the following:\n - `http://localhost:8080` if you are [testing the backend locally](/endpoints/docs/frameworks/java/test-deploy#running_and_testing_api_backends_locally).\n -\n `https://`\u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e`.appspot.com`,\n replacing \u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e\n with your App Engine project ID if you are deploying your\n backend API to your production App Engine.\n\n | **Important:** You must specify the site or host name under **Authorized JavaScript origins** using `https` for this to work with Cloud Endpoints, unless you are testing with `localhost`, in which case you must use `http`.\n8. Click **Create** .\n\n\n You use the generated client ID in your API backend and in your client\n application.\n\nWhat's next\n-----------\n\nFor information about how to support authentication in your Android or\nJavaScript application, see the following:\n\n- [Authenticating users](/endpoints/docs/frameworks/python/authenticating-users)\n- [Making authenticated calls from an Android client](/endpoints/docs/frameworks/python/consume_android#making_authenticated_calls)"]]