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?
2
votes
1 Answers
1
votes
You have 2 solutions:
- As John commented,
- Install the gcloud SDK on your computer.
- Authenticate yourselves with the command
gcloud auth loginorgcloud init(proposed at the end of the installation) - Generate an access token
gcloud auth print-access-tokenand 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.