Reputation: 521
I have a default n1 instance on the GCloud with preinstalled java and latest google sdk. When I run code locally within appengine:devserver which connects to the real pubsub subscription, it works correct. If I do the same on the Instance I get an authentication error:
[INFO] SEVERE: 401 OK
[INFO] {
[INFO] "code" : 401,
[INFO] "errors" : [ {
[INFO] "domain" : "global",
[INFO] "message" : "Request had invalid authentication credentials.",
[INFO] "reason" : "unauthorized"
[INFO] } ],
[INFO] "message" : "Request had invalid authentication credentials.",
[INFO] "status" : "UNAUTHENTICATED"
[INFO] }
All permissions are full or read/write/enabled for this instance. I absolutely have no idea why error happens?
I did gcloud init
with the same credentials locally and on the instance.
upd: I also tested pulling: gcloud beta pubsub subscriptions pull mysubscription-tag
- ok
Upvotes: 1
Views: 971
Reputation: 521
Simply had to run gcloud beta auth application-default login
.
But I spent a half of a day until found it there.
I thought it should be enough to gcloud init
. As alternative you can use google authentication via Google OAuth2 but that is hard way.
Upvotes: 2