Fetch AccessTokens from Azure AD

Not applicable

@Dino

I am trying to POST a request to Azure AD token endpoint to get back the response with AccessTokens but getting 400-Bad Request Error, I tries the same endpoint with POSTMAN and its working.

I have createrd a proxy before the Azure AD token endpoint and sending a POST request to that endpoint and using AssignMessage Policy to set the x-www-form-urlencoded payload.

I am observing that while tracing the request, everything is alright but content-Length(request header) is becoming 0, which is not the case with postman where I am setting payload manually.

My AssignMessage policy looks like this :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Message-1">
<DisplayName>Assign Message-1</DisplayName>
<Properties/>
<Set>
<Payload contentType="application/x-www-form-urlencoded">
client_id=urlencodedclientid
scope=https%3A%2F%2Fgraph.microsoft.com%2F.default
client_secret=urlencodedclientsecret
grant_type=client_credentials </Payload>
</Set>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
<!-- <AssignTo createNew="false" transport="http" type="request"/> -->
</AssignMessage>


Any advice will helpful

Solved Solved
0 2 905
1 ACCEPTED SOLUTION

Hi @Bhanu Prakash

Try with this policy

<?xml version="1.0" encoding="UTF-8"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Message-1">
   <DisplayName>Assign Message-1</DisplayName>
   <Properties />
   <Set>
      <FormParams>
        <FormParam name="client_id">{urlencodedclientid}</FormParam> <!-- variable that holds the value of client id you want to pass -->
        <FormParam name="client_secret">{urlencodedclientsecret}</FormParam> <!-- variable that holds the value of client secret you want to pass -->
        <FormParam name="scope">https%3A%2F%2Fgraph.microsoft.com%2F.default</FormParam>
        <FormParam name="grant_type">client_credentials</FormParam>
      </FormParams>
   </Set>
   <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
   <!-- <AssignTo createNew="false" transport="http" type="request"/> -->
</AssignMessage>

View solution in original post

2 REPLIES 2

Hi @Bhanu Prakash

Try with this policy

<?xml version="1.0" encoding="UTF-8"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Message-1">
   <DisplayName>Assign Message-1</DisplayName>
   <Properties />
   <Set>
      <FormParams>
        <FormParam name="client_id">{urlencodedclientid}</FormParam> <!-- variable that holds the value of client id you want to pass -->
        <FormParam name="client_secret">{urlencodedclientsecret}</FormParam> <!-- variable that holds the value of client secret you want to pass -->
        <FormParam name="scope">https%3A%2F%2Fgraph.microsoft.com%2F.default</FormParam>
        <FormParam name="grant_type">client_credentials</FormParam>
      </FormParams>
   </Set>
   <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
   <!-- <AssignTo createNew="false" transport="http" type="request"/> -->
</AssignMessage>

Thanks @Sai Saran Vaidyanathan for addressing it.

It worked for me.

I figured out one more way.
I used a JavaScript policy to just before the AssignMessage policy and set the whole payload in a variable and referred that variable in the AssignMessage policy.