Luis Medeiros
Luis Medeiros

Reputation: 73

Error connecting Google AutoML API with API KEY

I am trying to connect in the API using the link below by Postman

POST https://automl.googleapis.com/v1/projects/*****/locations/us-central1/models/*****:predict?key=*****

But I am getting the message below:

{
  "error": {
    "code": 401,
    "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED"
  }
}

KEY is authorized to use the API.

Upvotes: 0

Views: 427

Answers (2)

Rondo
Rondo

Reputation: 3721

You can generate a bearer token via the gcloud command. First authenticate an account locally (service account or not) and make that account active. Then run gcloud auth application-default print-access-token

For cURL, setting the Authorization header field looks like this:

-H "Authorization: Bearer "$(gcloud auth application-default print-access-token)

Upvotes: 0

Pievis
Pievis

Reputation: 1994

Only a limited number of Google APIs can be used via an API key, look here. I don't think AutoML APIs support key-based access.

For Postman, you can generate an access token using the OAuth2 playground, but if you are going to develop an integration, service account credentials is the way to go :)

Upvotes: 2

Related Questions