SC-googleapis - how to Service callout to googleapis

Hi,

I would like to create a working service callout to the service below - the URL is correct.

I fail with the following error message:

 

 

{
    "fault": {
        "faultstring": "Execution of ServiceCallout SC-googleapis failed. Reason: ResponseCode 401 is treated as error",
        "detail": {
            "errorcode": "steps.servicecallout.ExecutionFailed"
        }
    }
}

 

 

 

 

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout continueOnError="false" enabled="true" name="SC-googleapis">
  <DisplayName>SC-googleapis</DisplayName>
  <Properties/>
  <Request clearPayload="true" variable="myRequest">
    <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    <Set>
      <Verb>GET</Verb>
      <Headers>
        <Header name="Accept">application/json</Header>
      </Headers>
    </Set>
  </Request>
  <Response>calloutResponse</Response>
  <HTTPTargetConnection>
    <Properties/>
    <URL>https://apigee.googleapis.com/v1/organizations/{organization.name}/environments/{environment.name}/deployments</URL>
  </HTTPTargetConnection>
</ServiceCallout>

 

 

I'm new to apigee and would need very detailed help 🙂 

Can someone explain to me how to achieve this ?

Thank you

0 2 91
2 REPLIES 2

It appears you are missing the Google Authentication element in your Service Callout policy causing it to fail. As an example ...

<Authentication>
  <GoogleAccessToken>
    <Scopes>
      <Scope>https://www.googleapis.com/auth/cloud-platform</Scope>
    </Scopes>
  </GoogleAccessToken>
</Authentication>

You should also read through this page to understand how to configure Google Auth and how it works.
https://cloud.google.com/apigee/docs/api-platform/security/google-auth/overview

Lastly, its frowned upon to invoke Apigee APIs as part of a proxy flow. There are certainly some cases where it makes sense, but generally speaking its a bad practice and the anti-pattern is documented here. Food for thought.

Thank you this solved it.