Skip to content

Commit 2f1e02a

Browse files
authored
Merge pull request #56888 from KingdomOfEnds/digital-twins-oauth
Digital Twins Postman and OAuth
2 parents c7e88e5 + a2e0fe1 commit 2f1e02a

File tree

6 files changed

+101
-32
lines changed

6 files changed

+101
-32
lines changed

articles/digital-twins/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
href: how-to-user-defined-functions.md
5353
- name: How to route events and messages via endpoints
5454
href: how-to-egress-endpoints.md
55+
- name: How to configure Postman
56+
href: how-to-configure-postman.md
5557
- name: How to add blobs to objects
5658
href: how-to-add-blobs.md
5759
- name: How to use Digital Twins Swagger
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
title: How to configure Postman for Azure Digital Twins | Microsoft Docs
3+
description: How to configure Postman for Azure Digital Twins
4+
author: kingdomofends
5+
manager: alinast
6+
ms.service: digital-twins
7+
services: digital-twins
8+
ms.topic: conceptual
9+
ms.date: 11/13/2018
10+
ms.author: adgera
11+
---
12+
13+
# How to configure Postman for Azure Digital Twins
14+
15+
This article describes how to configure an Azure Active Directory (Azure AD) application to use the OAuth 2.0 implicit grant flow. Then, it discusses how to configure the Postman REST client to make token-bearing HTTP requests to your Management APIs.
16+
17+
## Postman summary
18+
19+
Get started on Azure Digital Twins by using a REST client tool such as [Postman](https://www.getpostman.com/) to prepare your local testing environment. The Postman client helps to quickly create complex HTTP requests. Download the desktop version of the Postman client by going to [www.getpostman.com/apps](https://www.getpostman.com/apps).
20+
21+
[Postman](https://www.getpostman.com/) is a REST testing tool that locates key HTTP request functionalities into a useful desktop and plugin-based GUI. Through the Postman client, solutions developers can specify the kind of HTTP request (POST, GET, UPDATE, PATCH, and DELETE), API endpoint to call, and use of SSL. Postman also supports adding HTTP request headers, parameters, form-data, and bodies.
22+
23+
## Configure Azure Active Directory to use the OAuth 2.0 implicit grant flow
24+
25+
Configure your Azure AD app to use the OAuth 2.0 implicit grant flow.
26+
27+
1. Follow the steps in [this quickstart](https://docs.microsoft.com/azure/active-directory/develop/quickstart-v1-integrate-apps-with-azure-ad) to create an Azure AD application of type Native. Or you can reuse an existing Native app registration.
28+
29+
1. Under **Required permissions**, enter `Azure Digital Twins` and select **Delegated Permissions**. Then select **Grant Permissions**.
30+
31+
![Azure AD app registrations add api](../../includes/media/digital-twins-permissions/aad-app-req-permissions.png)
32+
33+
1. Click **Manifest** to open the application manifest for your app. Set *oauth2AllowImplicitFlow* to `true`.
34+
35+
![Azure AD implicit flow][1]
36+
37+
1. Configure a **Reply URL** to [`https://www.getpostman.com/oauth2/callback`](https://www.getpostman.com/oauth2/callback).
38+
39+
![Azure AD Reply URL][2]
40+
41+
1. Copy and keep the **Application ID** of your Azure AD app. It is used below.
42+
43+
## Configure the Postman client
44+
45+
Next, set up and configure Postman to obtain an Azure AD token. Afterwards, make an authenticated HTTP request to Azure Digital Twins using the acquired token:
46+
47+
1. Go to [www.getpostman.com]([https://www.getpostman.com/) to download the app.
48+
1. Ensure that your **Authorization URL** is correct. It should take the format:
49+
50+
```plaintext
51+
https://login.microsoftonline.com/YOUR_AZURE_TENANT.onmicrosoft.com/oauth2/authorize?resource=YOUR_RESOURCE_ID
52+
```
53+
54+
| Name | Replace with | Example |
55+
|---------|---------|---------|
56+
| YOUR_AZURE_TENANT | The name of your tenant or organization | `microsoft` |
57+
| YOUR_RESOURCE_ID | The resource ID | `10b07f429-9f4b-4714-9392-cc5e8e80c8b0` |
58+
59+
1. Select the **Authorization** tab, select **OAuth 2.0**, and then select **Get New Access Token**.
60+
61+
| Field | Value |
62+
|---------|---------|
63+
| Grant Type | `Implicit` |
64+
| Callback URL | [`https://www.getpostman.com/oauth2/callback`](https://www.getpostman.com/oauth2/callback) |
65+
| Auth URL | Use the **Authorization URL** from step 2 above |
66+
| Client ID | Use the **Application ID** for the Azure AD app that was created or repurposed from the previous section |
67+
| Scope | leave blank |
68+
| State | leave blank |
69+
| Client Authentication | `Send as Basic Auth header` |
70+
71+
1. The client should now look like:
72+
73+
![Postman client example][3]
74+
75+
1. Select **Request Token**.
76+
77+
>[!NOTE]
78+
>If you receive the error message "OAuth 2 couldn’t be completed," try the following:
79+
> * Close Postman, and reopen it and try again.
80+
81+
1. Scroll down, and select **Use Token**.
82+
83+
## Next steps
84+
85+
To learn about authenticating with the Management APIs, read [Authenticate with APIs](./security-authenticating-apis.md).
86+
87+
<!-- Images -->
88+
[1]: media/how-to-configure-postman/implicit-flow.png
89+
[2]: media/how-to-configure-postman/reply-url.png
90+
[3]: media/how-to-configure-postman/postman-oauth-token.png
43.7 KB
Loading
19.6 KB
Loading
32.5 KB
Loading

articles/digital-twins/security-authenticating-apis.md

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ manager: alinast
66
ms.service: digital-twins
77
services: digital-twins
88
ms.topic: conceptual
9-
ms.date: 10/02/2018
9+
ms.date: 11/13/2018
1010
ms.author: lyrana
1111
---
1212

@@ -30,39 +30,16 @@ The Windows Azure Authentication Library offers many ways to acquire Active Dire
3030

3131
## Call Digital Twins from a middle-tier web API
3232

33-
When developers architect Digital Twins solutions, they typically create a middle-tier application or API. The app or API then calls the Digital Twins API downstream. Users first authenticate to the mid-tier application, and then an on-behalf-of token flow is used to call downstream. For instructions about how to orchestrate the on-behalf-of flow, see [this page](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow). You also can view code samples on [this page](https://azure.microsoft.com/resources/samples/active-directory-dotnet-webapi-onbehalfof/).
33+
When developers architect Digital Twins solutions, they typically create a middle-tier application or API. The app or API then calls the Digital Twins API downstream. To support this standard web solution architecture, make sure that users first:
3434

35+
1. Authenticate with the middle-tier application
36+
1. An OAuth 2.0 On-Behalf-Of token is acquired during authentication
37+
1. The acquired token is then used to authenticate with or call APIs that are further downstream using the On-Behalf-Of flow
3538

36-
## Test with the Postman client
37-
38-
To get up and running with the Digital Twins APIs, you can use a client such as Postman as an API environment. Postman helps you create complex HTTP requests quickly. The following steps show how to get an Azure AD token that's needed to call Digital Twins within the Postman UI.
39-
40-
41-
1. Go to https://www.getpostman.com/ to download the app.
42-
1. Follow the steps in [this quickstart](https://docs.microsoft.com/azure/active-directory/develop/quickstart-v1-integrate-apps-with-azure-ad) to create an Azure AD application. Or you can reuse an existing registration.
43-
1. Under **Required permissions**, enter “Azure Digital Twins” and select **Delegated Permissions**. Then select **Grant Permissions**.
44-
1. Open the application manifest, and set **oauth2AllowImplicitFlow** to true.
45-
1. Configure a reply URL to [https://www.getpostman.com/oauth2/callback](https://www.getpostman.com/oauth2/callback).
46-
1. Select the **Authorization** tab, select **OAuth 2.0**, and then select **Get New Access Token**.
47-
48-
|**Field** |**Value** |
49-
|---------|---------|
50-
| Grant type | Implicit |
51-
| Callback URL | [https://www.getpostman.com/oauth2/callback](https://www.getpostman.com/oauth2/callback) |
52-
| Auth URL | https://login.microsoftonline.com/<Your Azure AD Tenant e.g. Contoso>.onmicrosoft.com/oauth2/authorize?resource=0b07f429-9f4b-4714-9392-cc5e8e80c8b0 |
53-
| Client ID | Use the application ID for the Azure AD app that was created or repurposed from Step 2. |
54-
| Scope | Leave blank. |
55-
| State | Leave blank. |
56-
| Client authentication | Send as a Basic Auth header. |
57-
58-
1. Select **Request Token**.
59-
60-
>[!NOTE]
61-
>If you receive the error message "OAuth 2 couldn’t be completed," try the following:
62-
> * Close Postman, and reopen it and try again.
63-
64-
1. Scroll down, and select **Use Token**.
39+
For instructions about how to orchestrate the on-behalf-of flow, see [OAuth 2.0 On-Behalf-Of flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow). You also can view code samples in [Calling a downstream web API](https://azure.microsoft.com/resources/samples/active-directory-dotnet-webapi-onbehalfof/).
6540

6641
## Next steps
6742

68-
To learn about Azure Digital Twins security, read [Create and manage role assignments](./security-create-manage-role-assignments.md).
43+
To configure and test Azure Digital Twins using the OAuth 2.0 implicit grant flow, read [Configure Postman](./how-to-configure-postman.md).
44+
45+
To learn about Azure Digital Twins security, read [Create and manage role assignments](./security-create-manage-role-assignments.md).

0 commit comments

Comments
 (0)