Die Produktsuche befindet sich im Wartungsmodus. Für eine bessere Skalierbarkeit und dieselben Funktionen wie bei der Produktsuche können Sie das Vision Warehouse verwenden.
Sobald Sie fertig sind, wird Ihr Dienstkontoschlüssel heruntergeladen und im Standardspeicherort Ihres Browsers gespeichert.
Entscheiden Sie anschließend, ob Sie Ihre Dienstkontoauthentifizierung als Inhabertoken bereitstellen oder die Standardanmeldedaten für Anwendungen nutzen möchten.
Inhabertoken
Wenn Sie die Vision API direkt aufrufen, z. B. über eine HTTP-Anfrage mit cURL, übergeben Sie Ihre Authentifizierung als Inhabertoken in einem Authorization-Header. So rufen Sie ein Inhabertoken über Ihr Dienstkonto ab:
Wenn Sie die Vision API über eine Clientbibliothek aufrufen, verwenden Sie Standardanmeldedaten für Anwendungen.
Dienste, die Standardanmeldedaten für Anwendungen verwenden, erwarten diese innerhalb der Umgebungsvariable GOOGLE_APPLICATION_CREDENTIALS. Sofern Sie nicht ausdrücklich andere Anmeldedaten, wie zum Beispiel Nutzeranmeldedaten, als Standardanmeldedaten für Anwendungen verwenden möchten, sollte diese Umgebungsvariable auf Ihre Dienstkonto-Schlüsseldatei verweisen.
Ersetzen Sie PATH_TO_KEY_FILE durch den Pfad zu Ihrer JSON-Dienstkontodatei.
GOOGLE_APPLICATION_CREDENTIALS muss genau wie oben dargestellt eingegeben werden. Es handelt sich nicht um einen Platzhalter.
API-Schlüssel verwenden
Sie können einen Google Cloud Console API-Schlüssel zur Authentifizierung bei der Vision API verwenden.
[[["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-08-19 (UTC)."],[],[],null,["# Authenticating to the Cloud Vision API\n\nUsing a service account\n-----------------------\n\nUsing a service account to authenticate is the preferred method. To use a\nservice account to authenticate to the Vision API:\n\n1. Follow the instructions to [create a service account](/iam/docs/creating-managing-service-accounts#creating_a_service_account). Select **JSON** as your key type.\n\nOnce complete, your service account key is downloaded to your browser's\ndefault location.\n\nNext, decide whether you'll provide your service account authentication as a\n**bearer token** or using **application default credentials**.\n\n### Bearer tokens\n\nIf you're calling the Vision API directly, such as by making an HTTP request\nwith cURL, you'll pass your authentication as a bearer token in an\n`Authorization` header. To obtain a bearer token using your service account:\n\n1. [Install the gcloud CLI](/sdk/downloads#interactive).\n2. Authenticate to your service account, replacing `KEY_FILE` below with the\n path to your service account key file:\n\n gcloud auth activate-service-account --key-file KEY_FILE\n\n3. Obtain an authorization token using your service account:\n\n gcloud auth print-access-token\n\n The command returns an access token value.\n4. When calling the API, obtain an authorization token using your service\n account in an `Authorization` header:\n\n curl -s -H \"Authorization: Bearer $(gcloud auth application-default print-access-token)\" \\\n -H \"Content-Type: application/json\" \\\n \"https://vision.googleapis.com/v1/images:annotate\" -d @request.json\n\n### Application default credentials\n\nIf you're using a client library to call the Vision API, use\n[Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials) (ADC).\nServices using ADC look for credentials within a `GOOGLE_APPLICATION_CREDENTIALS`\nenvironment variable. Unless you specifically wish to have ADC use other\ncredentials (for example, user credentials), we recommend you set this\nenvironment variable to point to your service account key file. \n\n```\nexport GOOGLE_APPLICATION_CREDENTIALS=PATH_TO_KEY_FILE\n```\n\nReplace `PATH_TO_KEY_FILE` with the path to your JSON service account file.\n`GOOGLE_APPLICATION_CREDENTIALS` should be written out as-is (it's not a\nplaceholder in the example above).\n\nUsing an API key\n----------------\n\nYou can use a Google Cloud console API key to authenticate to the Vision API.\n\nTo do so:\n\n1. Follow the instructions to\n [create an API key for your Google Cloud console project](https://support.google.com/cloud/answer/6158862?hl=en).\n\n2. When making any Vision API request, pass your key as the value of a `key`\n parameter. For example:\n\n POST https://vision.googleapis.com/v1/images:annotate?key=YOUR_API_KEY\n\nMake sure to read\n[Best practices for securely using API keys](https://support.google.com/cloud/answer/6310037?hl=en&ref_topic=6262490)\nto prevent unauthorized use of your API key."]]