4.2 Getting a Client Access Token

This example of the GetClientAccessToken operation, as defined in section 3.1.4.4, shows how the client retrieves a client access token for a mail add-in specified by the Id element of the TokenRequest element, as described in section 3.1.4.4.3.3. The ID for the app is in the manifest file.

 <?xml version="1.0" encoding="UTF-8"?>
 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
                xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
            xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
   <soap:Header>
     <t:RequestServerVersion Version="Exchange2013" />
   </soap:Header>
   <soap:Body>
     <m:GetClientAccessToken>
       <m:TokenRequests>
          <t:TokenRequest>
            <t:Id>1C50226D-04B5-4AB2-9FCD-42E236B59E4B</t:Id>
            <t:TokenType>CallerIdentity</t:TokenType>
          </t:TokenRequest>
        </m:TokenRequests>
     </m:GetClientAccessToken>
   </soap:Body>
 </soap:Envelope>
  

The server sends the following successful response to the client. The token value has been abbreviated for readability.

 <?xml version="1.0" encoding="utf-8"?>
 <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Header>
     <h:ServerVersionInfo MajorVersion="15" 
                          MinorVersion="0" 
                          MajorBuildNumber="556" 
                          MinorBuildNumber="14" 
                          Version="Exchange2013" 
             xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" 
             xmlns="http://schemas.microsoft.com/exchange/services/2006/types" 
             xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
   </s:Header>
   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
           xmlns:xsd="http://www.w3.org/2001/XMLSchema">
     <m:GetClientAccessTokenResponse 
          xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" 
          xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
       <m:ResponseMessages>
         <m:GetClientAccessTokenResponseMessage ResponseClass="Success">
           <m:ResponseCode>NoError</m:ResponseCode>
           <m:Token>
             <t:Id>1C50226D-04B5-4AB2-9FCD-42E236B59E4B</t:Id>
             <t:TokenType>CallerIdentity</t:TokenType>
                   <t:TokenValue>eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImJRQnI5a3gwQ3plblFuaTFDdzJ6NWt1amJvYyJ9.</t:TokenValue>
             <t:TTL>479</t:TTL>
           </m:Token>
         </m:GetClientAccessTokenResponseMessage>
       </m:ResponseMessages>
     </m:GetClientAccessTokenResponse>
   </s:Body>
 </s:Envelope>
Show: