Graph API Code Sample: Authenticate and Read an Object From Windows Azure Active Directory (AD)
This code sample is a very basic console application written using Visual Studio 2010:
It demonstrates the following key features:
- How to request JWT token from Windows Azure AD Access Control using symmetric key.
- How to authenticate with the JWT token to Windows Azure AD using Graph API.
- How to read Windows Azure AD Object using Windows Azure AD Graph API.
It effectively reflects on the following scenario:
I have used the following resources to implement the sample:
- Sample Application for Azure Active Directory Graph API (RESTful API) . I cannibalizes code from this sample.
- Windows Azure Active Directory Graph Prerequisites. I have used this content to sign up for Office 365 which effectively gives me a Windows Azure AD subscription.
- How-to: Authenticate To Windows Azure AD Graph Using Windows Azure AD Access Control.I have used this sample to request JWT token. The difference is that in the How-To Client Certificate is used as a credential and in my sample I use symmetric key as a credential.
- How-To: Implement Role-Based Access Control When Using Windows Azure AD Graph.I have used this How-To to create Service Principal and add it to a proper role. If I don’t add the Service Principal to a proper role then the request for the JWT token will result in the insufficient privileges exception.
- How-to: Read Windows Azure Active Directory Objects Using Windows Azure AD Graph. I have used this How-To to request actual data from Windows Azure AD using Windows Azure AD Graph API.
Subscribe to Office 365 to get your Windows Azure AD subscription, grab the sample and start programming against it using the sample and the How-To’s.