Using Service CallOut to validate the O356 token and get the response

Hello All,

As In one apigee flow we are trying to connect thought service callout policy who validated the Bearer token passed into this and then extract the data to use to generate the apigee token using the client_credential method. @Dino @Anil Sagar @Naseer Mohammad could you please provide your inputs on this.

Below is our service callout policy

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="SC-ValidateOutlookTokenForUserProfile">
    <DisplayName>SC-ValidateOutlookTokenForUserProfile</DisplayName>
    <FaultRules/>
    <Properties/>
    <Request variable="OutlookProfileRequest">
        <Set>
            <Verb>GET</Verb>
            <Headers>
                <Header name="Authorization">{outlook_token}</Header>
                <Header name="Access-Control-Allow-Origin">*</Header>
            </Headers>
        </Set>
    </Request>
    <Response>OutlookProfileResponse</Response>
    <HTTPTargetConnection>
        <URL>https://graph.microsoft.com/v1.0/me/</URL>
    </HTTPTargetConnection>
</ServiceCallout>

When I hit the apigee API below is the response

{
    "fault": {
        "faultstring": "Execution of ServiceCallout SC-ValidateOutlookTokenForUserProfile failed. Reason: timeout occurred in SC-ValidateOutlookTokenForUserProfile",
        "detail": {
            "errorcode": "steps.servicecallout.ExecutionFailed"
        }
    }
}

And sometime below response:

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

Is the content of your variable outlook_token prefixed with "Bearer "? Otherwise I believe your Header should go like:

<Header name="Authorization">Bearer {outlook_token}</Header>

BTW, I do not think you need the extra header:

<Header name="Access-Control-Allow-Origin">*</Header>

@isaias.arellano.delgado I have tried this, it works and also gives me access_token but as I hit for multiple time again this gives an error and in next call, I get access_token and vice versa.

since just we have migrated this proxy from 4.14.07.00 to 4.17.09.00