O recurso de pesquisa de produtos está no modo de manutenção. Para aumentar a escalabilidade e ter a mesma funcionalidade da Pesquisa de produtos, use o Armazenamento do Vision.
Quando a operação estiver concluída, será feito o download da sua chave da conta de serviço para o local padrão do navegador.
Em seguida, decida se você fornecerá a autenticação da conta de serviço como um token do portador ou por meio de credenciais padrão do aplicativo.
Tokens do portador
Se você estiver chamando a API Vision diretamente, por exemplo, fazendo uma solicitação HTTP com cURL, transmita a autenticação como um token fo portador em um cabeçalho Authorization. Para receber um token do portador usando sua conta de serviço:
Se você estiver usando uma biblioteca de cliente para chamar a API Vision, use o Application Default Credentials (ADC).
Os serviços que utilizam o ADC procuram credenciais dentro de uma variável de ambiente GOOGLE_APPLICATION_CREDENTIALS. A menos que você queira especificamente que o ADC use outras credenciais (por exemplo, credenciais de usuário), aponte essa variável de ambiente para o arquivo de chave da conta de serviço.
Substitua PATH_TO_KEY_FILE pelo caminho para o arquivo da conta de serviço JSON.
Grave GOOGLE_APPLICATION_CREDENTIALS da maneira como aparece. Ele não é um marcador no exemplo acima.
Como usar uma chave de API
Use uma chave de API do Console do Google Cloud para fazer a autenticação na API Vision.
[[["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-04-21 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."]]