Hi all,

I am working with outlook Mail connector, I need to get access token from
refresh token . When I called API through the REST Client, It is working
but through the ESB , I am unable to get response. Please find the wire log
below.

[1] REST Client wire log

POST http://login.microsoftonline.com/common/oauth2/token
Content-Type: application/x-www-form-urlencoded
grant_type=refresh_token&client_id=xxxxxxxxxxxxxxx&client_secret=xxxxxxxxxxxxxxxx&refresh_token=AAABAAAAiL9Kn2Z27UubvWFPbm0gLSj81wVdCkSsT_rqg9I-CpL5pD0Dyru4vEg5o0nZe7YxCtM24jHbA5pSATNPyypxVyWq8WWnxNeLTMX7SFMzdaD5k0_qohsn4jqCar2U1_LTSgvFyCfvQhVKTF9ugOXE7ST9wjRe7XDAFwU75kMQ3kG1WUTI4lhhCYqoDS_KPwPFWE4_ntj8IYZ1BPkjuMAx514yuVURdjEvOluobippPQCtjWAK5X8bMIC6bLEoWj3D8x4hCDL32NVFBUYLgCKK0uaCFR8ulZKpjMc-8OMG9iS1jCPsIkF8O7-0rUBwr3mHCxycId0FDJIUuu2bqR1RRp3pzyzj3K0UfAUcWnkSZDrkeysPf4RbyQcyMhgRSZdhn7KL-8jQBcHvo2aPvvYErDpG4NnpeMrX5Iuk2amhtVzJYFUi27gTDt1XaPZQskbrYOw_GydTaRWvl0j8RBeG4xRHtv-dVnsphdSR6EkB0LKIFD6kWt0EyUmk4ZEf9OwgzjmPsTh0nxPGw-h1X02vGK58AL3CMx-Ot1TTInQEMObklysuTjZb4YjVUUiSBX4mnF0YtS1sSyQHRedgusCbMSAA&resource=https%3A%2F%
2Foutlook.office365.com
 -- response --
200 OK
Cache-Control:  no-cache, no-store
Pragma:  no-cache
Content-Type:  application/json; charset=utf-8
Expires:  -1
Server:  Microsoft-IIS/8.5
x-ms-request-id:  cea27772-54ae-404f-95a4-4e1c870394c4
client-request-id:  c61330e5-36d9-421c-b611-8d9a97789157
x-ms-gateway-service-instanceid:  ESTSFE_IN_199
x-content-type-options:  nosniff
Strict-Transport-Security:  max-age=31536000; includeSubDomains
P3P:  CP="DSP CUR OTPi IND OTRi ONL FIN"
Set-Cookie:  x-ms-gateway-slice=productiona; path=/; secure; HttpOnly
stsservicecookie=ests; path=/
X-Powered-By:  ASP.NET
Date:  Wed, 30 Mar 2016 10:06:32 GMT
Content-Length:  2924

[2] ESB wire log

 [2016-03-30 16:05:24,863] DEBUG - wire >> "POST /services/outLook_Init1
HTTP/1.1[\r][\n]"
[2016-03-30 16:05:24,863] DEBUG - wire >> "Host:
vives-thinkpad-t540p:8280[\r][\n]"
[2016-03-30 16:05:24,863] DEBUG - wire >> "Connection: keep-alive[\r][\n]"
[2016-03-30 16:05:24,863] DEBUG - wire >> "Content-Length: 796[\r][\n]"
[2016-03-30 16:05:24,863] DEBUG - wire >> "Cache-Control: no-cache[\r][\n]"
[2016-03-30 16:05:24,863] DEBUG - wire >> "Origin:
chrome-extension://mkhojklkhkdaghjjfdnphfphiaiohkef[\r][\n]"
[2016-03-30 16:05:24,863] DEBUG - wire >> "x-AnchorMailbox:
[email protected][\r][\n]"
[2016-03-30 16:05:24,863] DEBUG - wire >> "User-Agent: Mozilla/5.0 (X11;
Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.108
Safari/537.36[\r][\n]"
[2016-03-30 16:05:24,863] DEBUG - wire >> "Content-Type:
application/json[\r][\n]"
[2016-03-30 16:05:24,863] DEBUG - wire >> "Accept: */*[\r][\n]"
[2016-03-30 16:05:24,864] DEBUG - wire >> "Accept-Encoding: gzip,
deflate[\r][\n]"
[2016-03-30 16:05:24,864] DEBUG - wire >> "Accept-Language:
en-US,en;q=0.8[\r][\n]"
[2016-03-30 16:05:24,864] DEBUG - wire >> "Cookie:
exchangecookie=3b9aaeb9ce564f5b9852b715950fedd2[\r][\n]"
[2016-03-30 16:05:24,864] DEBUG - wire >> "[\r][\n]"
[2016-03-30 16:05:24,864] DEBUG - wire >> "{[\n]"
[2016-03-30 16:05:24,864] DEBUG - wire >> "
 
"refreshToken":"AAABAAAAiL9Kn2Z27UubvWFPbm0gLSj81wVdCkSsT_rqg9I-CpL5pD0Dyru4vEg5o0nZe7YxCtM24jHbA5pSATNPyypxVyWq8WWnxNeLTMX7SFMzdaD5k0_qohsn4jqCar2U1_LTSgvFyCfvQhVKTF9ugOXE7ST9wjRe7XDAFwU75kMQ3kG1WUTI4lhhCYqoDS_KPwPFWE4_ntj8IYZ1BPkjuMAx514yuVURdjEvOluobippPQCtjWAK5X8bMIC6bLEoWj3D8x4hCDL32NVFBUYLgCKK0uaCFR8ulZKpjMc-8OMG9iS1jCPsIkF8O7-0rUBwr3mHCxycId0FDJIUuu2bqR1RRp3pzyzj3K0UfAUcWnkSZDrkeysPf4RbyQcyMhgRSZdhn7KL-8jQBcHvo2aPvvYErDpG4NnpeMrX5Iuk2amhtVzJYFUi27gTDt1XaPZQskbrYOw_GydTaRWvl0j8RBeG4xRHtv-dVnsphdSR6EkB0LKIFD6kWt0EyUmk4ZEf9OwgzjmPsTh0nxPGw-h1X02vGK58AL3CMx-Ot1TTInQEMObklysuTjZb4YjVUUiSBX4mnF0YtS1sSyQHRedgusCbMSAA",[\n]"
[2016-03-30 16:05:24,864] DEBUG - wire >> "
 "clientSecret":"xxxxxxxxxxxxxxxxxx",[\n]"
[2016-03-30 16:05:24,864] DEBUG - wire >> "
 "clientId":"xxxxxxxxxxxxxxxxx",[\n]"
[2016-03-30 16:05:24,864] DEBUG - wire >> "
 "resource":"xxxxxxxxxxxxxxxxxxxx"[\n]"
[2016-03-30 16:05:24,864] DEBUG - wire >> "}[\n]"
[2016-03-30 16:05:24,882] DEBUG - wire << "POST /common/oauth2/token
HTTP/1.1[\r][\n]"
[2016-03-30 16:05:24,883] DEBUG - wire << "Accept-Language:
en-US,en;q=0.8[\r][\n]"
[2016-03-30 16:05:24,883] DEBUG - wire << "Cookie:
exchangecookie=3b9aaeb9ce564f5b9852b715950fedd2[\r][\n]"
[2016-03-30 16:05:24,883] DEBUG - wire << "Host: login.microsoftonline.com
[\r][\n]"
[2016-03-30 16:05:24,883] DEBUG - wire << "Accept-Encoding: gzip,
deflate[\r][\n]"
[2016-03-30 16:05:24,883] DEBUG - wire << "Origin:
chrome-extension://mkhojklkhkdaghjjfdnphfphiaiohkef[\r][\n]"
[2016-03-30 16:05:24,884] DEBUG - wire << "x-AnchorMailbox:
[email protected][\r][\n]"
[2016-03-30 16:05:24,884] DEBUG - wire << "Content-Type:
application/x-www-form-urlencoded; charset=UTF-8[\r][\n]"
[2016-03-30 16:05:24,884] DEBUG - wire << "Accept: */*[\r][\n]"
[2016-03-30 16:05:24,884] DEBUG - wire << "Cache-Control: no-cache[\r][\n]"
[2016-03-30 16:05:24,884] DEBUG - wire << "Transfer-Encoding:
chunked[\r][\n]"
[2016-03-30 16:05:24,884] DEBUG - wire << "Connection: Keep-Alive[\r][\n]"
[2016-03-30 16:05:24,884] DEBUG - wire << "User-Agent:
Synapse-PT-HttpComponents-NIO[\r][\n]"
[2016-03-30 16:05:24,884] DEBUG - wire << "[\r][\n]"
[2016-03-30 16:05:24,884] DEBUG - wire << "322[\r][\n]"
[2016-03-30 16:05:24,884] DEBUG - wire <<
"refresh_token=AAABAAAAiL9Kn2Z27UubvWFPbm0gLSj81wVdCkSsT_rqg9I-CpL5pD0Dyru4vEg5o0nZe7YxCtM24jHbA5pSATNPyypxVyWq8WWnxNeLTMX7SFMzdaD5k0_qohsn4jqCar2U1_LTSgvFyCfvQhVKTF9ugOXE7ST9wjRe7XDAFwU75kMQ3kG1WUTI4lhhCYqoDS_KPwPFWE4_ntj8IYZ1BPkjuMAx514yuVURdjEvOluobippPQCtjWAK5X8bMIC6bLEoWj3D8x4hCDL32NVFBUYLgCKK0uaCFR8ulZKpjMc-8OMG9iS1jCPsIkF8O7-0rUBwr3mHCxycId0FDJIUuu2bqR1RRp3pzyzj3K0UfAUcWnkSZDrkeysPf4RbyQcyMhgRSZdhn7KL-8jQBcHvo2aPvvYErDpG4NnpeMrX5Iuk2amhtVzJYFUi27gTDt1XaPZQskbrYOw_GydTaRWvl0j8RBeG4xRHtv-dVnsphdSR6EkB0LKIFD6kWt0EyUmk4ZEf9OwgzjmPsTh0nxPGw-h1X02vGK58AL3CMx-Ot1TTInQEMObklysuTjZb4YjVUUiSBX4mnF0YtS1sSyQHRedgusCbMSAA&grant_type=refresh_token&client_secret=xxxxxxxxxxxxxxx&client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&resource=https%3A%2F%
2Foutlook.office365.com[\r][\n]"
[2016-03-30 16:05:24,884] DEBUG - wire << "0[\r][\n]"
[2016-03-30 16:05:24,884] DEBUG - wire << "[\r][\n]"
[2016-03-30 16:05:24,953] DEBUG - wire >> "HTTP/1.1 404 Not Found[\r][\n]"
[2016-03-30 16:05:24,953] DEBUG - wire >> "Cache-Control: private[\r][\n]"
[2016-03-30 16:05:24,953] DEBUG - wire >> "Server:
Microsoft-IIS/8.5[\r][\n]"
[2016-03-30 16:05:24,954] DEBUG - wire >> "Set-Cookie:
x-ms-gateway-slice=productiona; path=/; secure; HttpOnly[\r][\n]"
[2016-03-30 16:05:24,954] DEBUG - wire >> "X-Powered-By: ASP.NET[\r][\n]"
[2016-03-30 16:05:24,954] DEBUG - wire >> "Date: Wed, 30 Mar 2016 10:35:23
GMT[\r][\n]"
[2016-03-30 16:05:24,954] DEBUG - wire >> "Content-Length: 0[\r][\n]"
[2016-03-30 16:05:24,954] DEBUG - wire >> "[\r][\n]"
[2016-03-30 16:05:24,957] DEBUG - wire << "HTTP/1.1 404 Not Found[\r][\n]"
[2016-03-30 16:05:24,958] DEBUG - wire << "Set-Cookie:
x-ms-gateway-slice=productiona; path=/; secure; HttpOnly[\r][\n]"
[2016-03-30 16:05:24,958] DEBUG - wire << "X-Powered-By: ASP.NET[\r][\n]"
[2016-03-30 16:05:24,958] DEBUG - wire << "Cache-Control: private[\r][\n]"
[2016-03-30 16:05:24,958] DEBUG - wire << "Date: Wed, 30 Mar 2016 10:35:24
GMT[\r][\n]"
[2016-03-30 16:05:24,958] DEBUG - wire << "Transfer-Encoding:
chunked[\r][\n]"
[2016-03-30 16:05:24,958] DEBUG - wire << "Connection: keep-alive[\r][\n]"


Please find the template here.

What could be the reason?





*Thank youVivekananthan Sivanayagam*

*Associate Software Engineer | WSO2*

*E:[email protected] <e%[email protected]>*
*M:+94752786138 <%2B94752786138>*
<?xml version="1.0" encoding="UTF-8"?>
<!--
   Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.

   WSO2 Inc. licenses this file to you under the Apache License,
   Version 2.0 (the "License"); you may not use this file except
   in compliance with the License.
   You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied. See the License for the
   specific language governing permissions and limitations
   under the License.
-->
<!-- Method Documentation URL: https://msdn.microsoft.com/en-us/library/azure/dn645542.aspx -->
<template name="getAccessToken" xmlns="http://ws.apache.org/ns/synapse";>

    <parameter name="refreshToken" description="value of the refresh token."/>
    <parameter name="clientSecret"
               description="The value of the key that contains the client password."/>
    <parameter name="clientId"
               description="The client ID of the client application that is registered in Azure AD."/>
    <parameter name="resource"
               description="The App ID URI of the web API."/>
    <sequence>
        <property name="uri.var.refreshToken" expression="$func:refreshToken"/>
        <property name="uri.var.clientSecret" expression="$func:clientSecret"/>
        <property name="uri.var.clientId" expression="$func:clientId"/>
        <property name="uri.var.resource" expression="$func:resource"/>

        <payloadFactory media-type="xml">
            <format>
                <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
                    <soapenv:Header></soapenv:Header>
                    <soapenv:Body>
                        <root>
                            <refresh_token>$1</refresh_token>
                            <grant_type>refresh_token</grant_type>
                            <client_secret>$2</client_secret>
                            <client_id>$3</client_id>
                            <resource>$4</resource>
                        </root>
                    </soapenv:Body>
                </soapenv:Envelope>
            </format>
            <args>
                <arg expression="$ctx:uri.var.refreshToken"/>
                <arg expression="$ctx:uri.var.clientSecret"/>
                <arg expression="$ctx:uri.var.clientId"/>
                <arg expression="$ctx:uri.var.resource"/>
            </args>
        </payloadFactory>

        <property name="messageType" value="application/x-www-form-urlencoded"
                  scope="axis2" />
        <header name="Content-Encoding" action="remove" scope="transport"/>
        <property name="REQUEST_HOST_HEADER" scope="axis2" value="login.microsoftonline.com"/>
        <header name="Transfer-Encoding" action="remove" scope="transport"/>
        <call>
            <endpoint>
                <http method="POST" uri-template="https://login.microsoftonline.com/common/oauth2/token"/>
            </endpoint>
        </call>
    </sequence>
</template>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to