Task: I want to store all logs from my local computer to the google logs.
The problem I faced is that I cannot create a service account with correct permissions. Even if I will give owner permission still getting I'm permission denied error (ACCESS_TOKEN - its token from account json key):
cat data.json | http POST
"https://logging.googleapis.com/v2/entries:write"
Authorization:"Bearer $ACCESS_TOKEN"
Response:
{
"error": {
"code": 403,
"message": "The caller does not have permission",
"status": "PERMISSION_DENIED"
}
}
Currently, I have set: and it still not working.
While debugging I decided to use the personal account with that type of access:
And request with a token from my account works perfectly fine:
$ cat data.json | http POST
"https://logging.googleapis.com/v2/entries:write"
Authorization:"Bearer `gcloud auth application-default print-access-token`"
HTTP/1.1 200 OK
Alt-Svc: quic=":443"; ma=2592000; v="44,43,39,35"
Cache-Control: private
Content-Encoding: gzip
Content-Type: application/json; charset=UTF-8
Date: Sun, 23 Dec 2018 21:38:05 GMT
Server: ESF
Transfer-Encoding: chunked
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
{}
But if I'm using exported stackdriver-station-1.json credentials-file with golang/nodejs app I'm getting permission denied error:
the same example using a console and ACCESS_TOKEN generated from exported json file:
$ cat data.json | http POST
"https://logging.googleapis.com/v2/entries:write"
Authorization:"Bearer $ACCESS_TOKEN"
HTTP/1.1 403 Forbidden
Alt-Svc: quic=":443"; ma=2592000; v="44,43,39,35"
Cache-Control: private
Content-Encoding: gzip
Content-Type: application/json; charset=UTF-8
Date: Sun, 23 Dec 2018 22:39:51 GMT
Server: ESF
Transfer-Encoding: chunked
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
{
"error": {
"code": 403,
"message": "The caller does not have permission",
"status": "PERMISSION_DENIED"
}
}
Any suggestions are welcome! For me, it seems like I'm missing some fundamental part of the google cloud permissions. Like I need to put some check mark in the cloud interface or something like that.