Dodji Aguessy
Dodji Aguessy

Reputation: 21

Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential automl

I am a novice developer who wants to learn how to use artificial intelligence. So I created model and it responds correctly according to the inputs. So I want to test using postman a call to the API to verify that everything works and I have an error in my call: "message": "Request had invalid authentication credentials. 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" I don't know how to authenticate myself to retrieve the access token. Could you help me find a solution please?

Upvotes: 2

Views: 2265

Answers (2)

litbe
litbe

Reputation: 507

I've encountered a similar error with Google calendar in SwiftUI. I fixed it by specifying the authorizer info from the signed-in user

let service = GTLRCalendarService()
service.authorizer = user.fetcherAuthorizer
service.executeQuery(insertQuery) { (ticket, object, error) ... }

A full sample app is available in github.

Upvotes: 0

guillaume blaquiere
guillaume blaquiere

Reputation: 75910

You have 2 solutions:

  • As John commented,
    • Install the gcloud SDK on your computer.
    • Authenticate yourselves with the command gcloud auth login or gcloud init (proposed at the end of the installation)
    • Generate an access token gcloud auth print-access-token and copy it
      • Tips: you can skip the 2 first steps if you use Cloud Shell
    • Add the access token to the header to your Postman request like this:
      • Key is "Authrorization"
      • Value is "Bearer "
    • The access token is valid 1H, then you have to generate a new one.
  • (Not recommended) Make your model public (i.e. unauthenticated) like this (only in command line, it doesn't work on the GUI)
gcloud ai-platform models add-iam-policy-binding --member="allUsers" \
  --role="roles/ml.modelOwner" <Model Name>

replace Model Name by your deployed model. However, it's only for test purpose. You have any filter and anyone can use it and you will pay for the processing incurs.

Upvotes: 2

Related Questions