Quantcast
Channel: Azure Active Directory forum
Viewing all articles
Browse latest Browse all 16000

PHP version of the Windows Azure Authentication Library (AAL)?

$
0
0

Hi All,

Is there PHP version of the Windows Azure Authentication Library (AAL)?

I have an ASP MVC Web API application that I have secured using the Azure Active Directory. It follows exactly the details outlined here: ADAL - Server to Server Authentication http://code.msdn.microsoft.com/windowsazure/AAL-Server-to-Server-9aafccc1 for the TelemetryServiceClient application).

I have looked at this http://www.windowsazure.com/en-us/develop/php/how-to-guides/web-sso/ but have not been able to adapt it (possibly because of my limited PHP knowledge). I am looking for some PHP to acquire the token give a clientId and aclientSecret. (My .NET version below)

For a .NET client I use the AAL, which work very well (nice and simple). Is there an equivalent client AAL for PHP?

Many thanks,

Jeremy

stringtenant ="https://login.windows.net/mytenant.onmicrosoft.com";

stringclientId ="c01d1aaf-4d5d-4b9e-9fa0-fac91e06e918";

stringclientSecret ="Xne6XEI4dTe1c311mDYZLWleF89R59ZvXi3vvyV9M/w=";

stringappIdUri ="http://myapp.azurewebsites.net";   // App Id uri

AuthenticationContextauthenticationContext =newAuthenticationContext(tenant);

           

HttpClienthttpClient =newHttpClient();

// Add an Accept header for JSON format.

httpClient.DefaultRequestHeaders.Accept.Add(new

 MediaTypeWithQualityHeaderValue("application/json"));

// Client Credential Object used while Acquiring a token from Windows Azure AD

ClientCredentialclientCred =newClientCredential(clientId,clientSecret);

AuthenticationResultauthenticationResult =authenticationContext.AcquireToken(appIdUri,clientCred);                   

if (authenticationResult != null)

{

   httpClient.DefaultRequestHeaders.Clear();

   // Add authorization header to HttpClient

   httpClient.DefaultRequestHeaders.Authorization =

       newAuthenticationHeaderValue("Bearer",authenticationResult.AccessToken);

                       

  // Call the web API

  HttpResponseMessageresponse = 

     httpClient.GetAsync("http://myapp.azurewebsites.net/api/results").Result;

  // Process response                   

  ...

}

Viewing all articles
Browse latest Browse all 16000

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>