Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to use service callout for google access token

I am designing a proxy for this API because the API has this Authorization:

curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json"

I set service callout、Extract token、AssingMessage to achieve the goal。But I keep getting the 401 message of token error.("message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.")
Is there any wrong setting in my service callout?

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="SC-auth">
  <DisplayName>SC-auth</DisplayName>
  <Request>
    <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    <Set>
      <Headers>
        <Header name="Content-Type">application.json</Header>
        <Header name="Authorization">bearer</Header>
      </Headers>
      <FormParams>
        <FormParam name="grant_type">refresh_token</FormParam>
        <FormParam name="refresh_token">{request.formparam.a}</FormParam>
      </FormParams>
    </Set>
  </Request>
  <Response>accessTokenResponse</Response>
  <Timeout>30000</Timeout>
  <HTTPTargetConnection>
    <Authentication>
      <HeaderName ref="Authorization">STRING</HeaderName>
      <GoogleAccessToken>
        <Scopes>
        </Scopes>
      </GoogleAccessToken>
    </Authentication>
  </HTTPTargetConnection>
</ServiceCallout>
0 3 289
3 REPLIES 3