Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Wenn der Zugriff auf das API-Back-End nur mit Authentifizierung möglich sein soll, müssen die erforderlichen Client-IDs abgerufen und über das richtige API-Decorator-Argument an das Back-End übergeben werden.
Android
Zum Erstellen einer Android-Client-ID für OAuth 2.0 benötigen Sie den Fingerabdruck eines Zertifikatschlüssels. Wenn Sie Android Studio verwenden, werden automatisch ein Keystore und ein Schlüssel für die Fehlerbehebung erstellt. Für Testzwecke reicht der Fehlerbehebungsschlüssel aus, während für die Produktion ein Releaseschlüssel erforderlich ist.
Das Standardpasswort des Schlüsselspeichers der Fehlerbehebung lautet android und der Schlüsselalias androiddebugkey. Der Standardspeicherort für Linux und macOS ist ~/.android/debug.keystore.
Generieren Sie einen Fehlerbehebungs- oder Releaseschlüssel für Ihre Android-Anwendung, sofern nicht bereits geschehen. Wenn Sie Android Studio verwenden, wird beim ersten Erstellen eines Android-Projekts im Keystore für die Fehlerbehebung automatisch ein Fehlerbehebungsschlüssel generiert.
Den Fingerabdruck des Schlüssels können Sie in einem Linux- oder macOS-Terminalfenster mit dem im Java SDK enthaltenen keytool anfordern:
Die Ausgabe zeigt einen Fingerabdruck an, der in etwa so aussieht:
DA:39:A3:EE:5E:6B:4B:0D:32:55:BF:EF:95:60:18:90:AF:D8:07:09
Kopieren und speichern Sie den Fingerabdruck des Schlüssels, der nach Ausführung des obigen keytool-Befehls angezeigt wird. Sie müssen den Fingerabdruck angeben, um die Android-Client-ID in der Google Cloud Console zu generieren.
Rufen Sie in der Google Cloud Console die Seite Anmeldedaten auf.
Wählen Sie aus der Projektliste das Projekt aus, in dem sich die API befindet.
Wenn Sie zum ersten Mal eine Client-ID in diesem Projekt erstellen, führen Sie die Unterschritte aus, um zum OAuth-Zustimmungsbildschirm zu gelangen. Fahren Sie andernfalls mit dem nächsten Schritt fort.
Klicken Sie auf OAuth-Zustimmungsbildschirm.
Geben Sie im Feld Name der Anwendung einen Namen ein.
Füllen Sie gegebenenfalls die restlichen Felder aus.
Klicken Sie auf Speichern.
Wählen Sie in der Drop-down-Liste Anmeldedaten erstellen die Option OAuth-Client-ID aus.
Wählen Sie als Anwendungstyp Android aus.
Geben Sie im Feld Name einen Namen für Ihre Client-ID ein.
Geben Sie im Feld Signaturzertifikat-Fingerabdruck den zuvor abgerufenen Fingerabdruck ein.
Geben Sie im Feld Paketname den Namen des Android-Anwendungspakets ein, wie in der Datei AndroidManifest.xml angegeben.
Klicken Sie auf Erstellen.
Die generierte Client-ID wird in Ihrem API-Back-End und in Ihrer Clientanwendung verwendet.
Webclient
Rufen Sie in der Google Cloud Console die Seite Anmeldedaten auf.
Wählen Sie aus der Projektliste das Projekt aus, in dem sich die API befindet.
Wenn Sie zum ersten Mal eine Client-ID in diesem Projekt erstellen, führen Sie die Unterschritte aus, um zum OAuth-Zustimmungsbildschirm zu gelangen. Fahren Sie andernfalls mit dem nächsten Schritt fort.
Klicken Sie auf OAuth-Zustimmungsbildschirm.
Geben Sie im Feld Name der Anwendung einen Namen ein.
Füllen Sie gegebenenfalls die restlichen Felder aus.
Klicken Sie auf Speichern.
Wählen Sie in der Drop-down-Liste Anmeldedaten erstellen die Option OAuth-Client-ID aus.
Wählen Sie als Anwendungstyp Webanwendung aus.
Geben Sie im Feld Name einen Namen für Ihre Client-ID ein.
Geben Sie im Feld Autorisierte JavaScript-Quellen eine der folgenden URLs ein:
https://YOUR_PROJECT_ID.appspot.com, wobei Sie YOUR_PROJECT_ID durch Ihre App Engine-Projekt-ID ersetzen, wenn Sie die Back-End API auf Ihrer Produktions-App Engine bereitstellen.
Klicken Sie auf Erstellen.
Sie verwenden die generierte Client-ID in Ihrem API-Back-End und in Ihrer Clientanwendung.
Weitere Informationen
Informationen darüber, wie Sie Authentifizierung in Ihrer Android- oder JavaScript-Anwendung unterstützen, finden Sie unter folgenden Links:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 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)"]]