Connecting to Microsoft Graph API

etlworks-azure

Microsoft Graph provides a unified programmability model that you can use to take advantage of the tremendous amount of data in Microsoft 365, Azure Active Directory, and other Microsoft services.

Read about Microsoft Graph and Microsoft Graph API.

This blog post provides step-by-step instruction for creating a connection to the Microsoft Graph API in Etlworks.

Registering your app with Azure AD endpoint

Assuming that you already have Office 365 or Azure account, the first step is to create an app and register it with Azure AD endpoint.

Step 1. Login to Azure Portal and select “Azure Active Directory” in the left side-bar.

Step 2. Select “App Registration” and click “New application registration”.

Step 3. Enter the name of the application, for example, Office 365 connector, select Web app / API in the “Application type” and enter https://api.etlworks.com in the “Sign-on URL”.

Step 4. Click “Create” and wait while application being created.

Step 5. Click “Settings” and then expand “Properties”. Copy and save somewhere “Application ID” and “App ID URI”. We will be using both later when creating a connection to the Microsoft Graph API.

Step 6. Expand “Required permissions” and click “Add”.

Step 7. Click “Select an API” and add all required APIs. For this example we will need Microsoft Graph.

Step 8. Click “Select permissions” and select Read all users’ full profiles.

Step 9. Click “Select” and “Done”.

Step 10. Expand “Keys”.

Step 11. Enter key parameters, for example, api key, Never expires, graph api key.

Step 12. Click “Save”. Copy and save the key value. It is not going to be available after you leave this screen.

Creating a connection to the Microsoft Graph API

In this section, we will be showing you how to create a connection to the Graph API endpoint which returns users in the Azure Active Directory for the specific Office 365 account.

Step 1. Add a new HTTP connection in Etlworks.

Step 2. Enter the following URL in the “URL” field.

https://graph.microsoft.com/v1.0/users

Step 3. Select GET as a “Method” and application/json as a “Content Type Header”.

Step 4. Add the following “Header” (name&value)

name=content-type
value=application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8

Step 5. Select OAuth2 for “Authentication”. In the “User” field enter the “Application ID” from step 5 of the “Register your app with Azure AD” and in the “Password” field enter the key value from step 12.

Step 6. In the “Authentication URL” field enter the “”App ID URI” from step 5 of the “Register your app with Azure AD”.

Step 7. Select POST for “HTTP Method for Token and OAuth2 Authentication”.

Step 8. Enter the following string in the “Authentication Request Payload” field:

&client_id={user}
&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default
&client_secret={password}
&grant_type=client_credentials

Step 9. Select application/x-www-form-urlencoded as an “Authentication Request Content Type”.

Step 10. Give the connection a name and save it.

Testing Microsoft Graph API connection

The following shows you how to test the connection using Explorer.

Step 1. If you don’t have it already create the JSON format. Use all the default settings.

Step 2. Go to Explorer, select the connection created in the previous section and click “expand” (down-arrow) button. Link the format created in step 1 to the connection.

Step 3. Click the “View Data” button to view the data in a grid format or “Raw Data” to view the data in the JSON format.

Author: Maksym Sherbinin

Co-founder of Etlworks.com, living in Pittsburgh, Pennsylvania

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s