I cannot figure out how to get a Bearer token from GCP that I can use in the authorization header for cURL.
According with the Google Public Documentation
If your application occupies the Authorization request header, you can
include the ID token in a Proxy-Authorization: Bearer header instead.
If a valid ID token is found in a Proxy-Authorization header, IAP
authorizes the request with it. After authorizing the request, IAP
passes the Authorization header to your application without processing
the content.
If no valid ID token is found in the Proxy-Authorization header, IAP
continues to process the Authorization header and strips the
Proxy-Authorization header before passing the request to your
application.
Bearer Token OIDC
This document also includes code samples to:
And in this link you can find more information about Verify Bearer Token in GCP
Bearer Token Auth
After some research I found two pages that describe How to provide your service account authentication as a Bearer token and How to send Curl POST request with Bearer Token Authorization Header.
The first one is part of the Google Developers public documentation, and describes the process to obtain a Bearer token with your service account.
Install the gcloud command line tool.
Authenticate to your service account. In the following command,
replace ${KEY_FILE}
with the path to your service account key
file:
gcloud auth activate-service-account
--key-file ${KEY_FILE}
Use your service account to obtain an authorization token:
gcloud auth print-access-token
The command returns an access token value.
When you use the API, pass the token value as a Bearer token in an
Authorization header. See the following example:
curl -X GET -H "X-Goog-User-Project: ${CLIENT_PROJECT}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${TOKEN}" \
"https://sasportal.googleapis.com/v1alpha1/customers"
Set ${CLIENT_PROJECT}
to the ID of the Google Cloud Project from
which you make the requests, and then set ${TOKEN}
to the
authorization token.
And in this link you will find information and examples about Curl Request With Bearer Token Authorization Header