It looks to me that there is some confusion here. Let me try to help.
1st, your service callout is mis-configured.
This part:
<ServiceCallout async="false" continueOnError="false" enabled="true" name="SC-auth">
<Request>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
<Set>
<Headers>
<Header name="Content-Type">application.json</Header>
<Header name="Authorization">bearer</Header>
</Headers>
<FormParams>...</FormParams>
</Set>
</Request>
…has two problems. First, if you are sending JSON, the content-type header should probably be “application/json” (with a slash) not application.json" (with a dot). Then you are using FormParams, which implies… you ARE NOT sending JSON. So those are in conflict. Either send JSON with the application/JSON content-type, or send form params with the application/x-www-form-urlencoded content-type. Choose one.
But that inconsistency is not why you are seeing an Authentication error. There is a second problem here - this section is setting the Authorization header to “bearer”. That’s not correct. An Authorization header should be “Bearer TOKEN” where TOKEN is replaced by an actual access token. So I think you need to remove or modify that configuration line. Probably, remove it, because…
In a later section it appears that you are using the Authentication tag.
<HTTPTargetConnection>
<URL>https://www.googleapis.com/auth/cloud-platform</URL>
<Authentication>
<HeaderName ref="Authorization">STRING</HeaderName>
<GoogleAccessToken>
<Scopes>
<Scope>https://www.googleapis.com/auth/cloud-platform</Scope>
</Scopes>
</GoogleAccessToken>
</Authentication>
</HTTPTargetConnection>
There are multiple problems here too. First you are using URL = https://www.googleapis.com/auth/cloud-platform That’s not a URL you will connect with. What is your goal? Normally you would use something like bigquery.googleapis.com to reach BQ, or storage.googleapis.com to reach Google Cloud Storage, or secretmanager.googleapis.com to reach the secret manager, etc. The URL https://www.googleapis.com/auth/cloud-platform doesn’t return anything, except the phrase “cloud platform”. It’s not a real service. So you need to figure out what service you’re trying to invoke.
Next, within the Authentication tag, you are using
<HeaderName ref="Authorization">STRING</HeaderName>
That is also wrong. The ref should refer to the name of a context variable. “Authorization” is not the name of a context variable, probably. Also, you probably don’t want to the HeaderName element here at all.
The purpose of the Authentication tag here is to tell Apigee “go get a token, and inject it into the Authorization header for me as a bearer token, before making this ServiceCallout request.” The HeaderName element allows you to modify the name of the header into which the bearer token will be inserted. So if you don’t want to use the Authorization header for some reason , the HeaderName element allows you to override it. You probably don’t want that, so omit that element here.
And if the Authentication tag tells Apigee to inject a header, then you do not need the Set/Headers/Header/@name=Authorization in the prior section.
Last, you are invoking your API Proxy with
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" ...
…which effectively is passing YOUR token into the proxy. I am not sure why you would do that, you haven’t explained.
You probably do not want that.
It seems like you are hacking around, without a lot of understanding of what you’re doing.
What is your goal here? Can you explain what you are trying to accomplish?