1
votes

I am writing an application to fetch query logs from google cloud sql using stack driver monitoring. I am able to retrieve the logs using API explorer. I will be using a curl call to download the logs.

curl --header "Authorization: Bearer ACCESS_TOKEN" --header 'Content-Type: application/json' --header 'x-referer: https://developers.google.com' -X POST --data '{"resourceNames":["projectname"],"filter":"logName=logname"}' "https://content-logging.googleapis.com/v2/entries:list?fields=entries(jsonPayload%2ClogName%2Coperation%2CreceiveTimestamp%2CtextPayload%2Ctimestamp)&key=APIkey"

API key is available in the interface. I have downloaded the json with client details. But I am not able to find any documentation on how to generate ACCESS_TOKEN in this case. Can someone please help me on this?

1

1 Answers

0
votes

You can try:

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

or set:

ACCESS_TOKEN="$(gcloud auth application-default print-access-token)"

and then:

curl --header "Authorization: Bearer ${ACCESS_TOKEN}" ...