You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/active-directory/develop/index.yml
+31-19Lines changed: 31 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -3,14 +3,14 @@
3
3
title: Microsoft identity platform (formerly Azure Active Directory for developers)
4
4
summary: Microsoft identity platform is an evolution of the Azure Active Directory (Azure AD) developer platform. It allows developers to build applications that sign in all Microsoft identities and get tokens to call Microsoft APIs such as Microsoft Graph or APIs that developers have built. It’s a full-featured platform that consists of an OAuth 2.0 and OpenID Connect standard-compliant authentication service, open-source libraries, application registration and configuration, robust conceptual and reference documentation, quickstart samples, code samples, tutorials, and how-to guides.
Copy file name to clipboardExpand all lines: articles/active-directory/develop/scenario-web-api-call-api-acquire-token.md
+30-1Lines changed: 30 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ ms.tgt_pltfrm: na
15
15
ms.workload: identity
16
16
ms.date: 05/07/2019
17
17
ms.author: jmprieur
18
-
ms.custom: aaddev
18
+
ms.custom: aaddev
19
19
#Customer intent: As an application developer, I want to know how to write a web API that calls web APIs by using the Microsoft identity platform for developers.
20
20
---
21
21
@@ -25,6 +25,8 @@ After you've built a client application object, use it to acquire a token that y
25
25
26
26
## Code in the controller
27
27
28
+
# [ASP.NET Core](#tab/aspnetcore)
29
+
28
30
Here's an example of code that's called in the actions of the API controllers. It calls a downstream API named *todolist*.
29
31
30
32
```csharp
@@ -66,6 +68,33 @@ public static string GetMsalAccountId(this ClaimsPrincipal claimsPrincipal)
66
68
}
67
69
```
68
70
71
+
# [Java](#tab/java)
72
+
Here's an example of code that's called in the actions of the API controllers. It calls the downstream API - Microsoft Graph.
A Python web API will need to use some middleware to validate the bearer token received from the client. The web API can then obtain the access token for downstream API using MSAL Python library by calling the [`acquire_token_on_behalf_of`](https://msal-python.readthedocs.io/en/latest/?badge=latest#msal.ConfidentialClientApplication.acquire_token_on_behalf_of) method. A sample demonstrating this flow with MSAL Python is not yet available.
Copy file name to clipboardExpand all lines: articles/active-directory/develop/scenario-web-api-call-api-app-configuration.md
+81-3Lines changed: 81 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ ms.tgt_pltfrm: na
15
15
ms.workload: identity
16
16
ms.date: 07/16/2019
17
17
ms.author: jmprieur
18
-
ms.custom: aaddev
18
+
ms.custom: aaddev
19
19
#Customer intent: As an application developer, I want to know how to write a web API that calls web APIs by using the Microsoft identity platform for developers.
20
20
---
21
21
@@ -25,6 +25,8 @@ After you've registered your web API, you can configure the code for the applica
25
25
26
26
The code that you use to configure your web API so that it calls downstream web APIs builds on top of the code that's used to protect a web API. For more information, see [Protected web API: App configuration](scenario-protected-web-api-app-configuration.md).
27
27
28
+
# [ASP.NET Core](#tab/aspnetcore)
29
+
28
30
## Code subscribed to OnTokenValidated
29
31
30
32
On top of the code configuration for any protected web APIs, you need to subscribe to the validation of the bearer token that you receive when your API is called:
@@ -44,15 +46,15 @@ public static IServiceCollection AddProtectedApiCallsWebApis(this IServiceCollec
The On-behalf-of (OBO) flow is used to obtain a token to call the downstream web API. In this flow, your web API receives a bearer token with user delegated permissions from the client application and then exchanges this token for another access token to call the downstream web API.
147
+
148
+
The code below uses Spring Security framework's `SecurityContextHolder` in the web API to get the validated bearer token. It then uses the MSAL Java library to obtain a token for downstream API using the `acquireToken` call with `OnBehalfOfParameters`. MSAL caches the token so that subsequent calls to the API can use `acquireTokenSilently` to get the cached token.
The On-behalf-of (OBO) flow is used to obtain a token to call the downstream web API. In this flow, your web API receives a bearer token with user delegated permissions from the client application and then exchanges this token for another access token to call the downstream web API.
216
+
217
+
A Python web API will need to use some middleware to validate the bearer token received from the client. The web API can then obtain the access token for downstream API using MSAL Python library by calling the [`acquire_token_on_behalf_of`](https://msal-python.readthedocs.io/en/latest/?badge=latest#msal.ConfidentialClientApplication.acquire_token_on_behalf_of) method. A sample demonstrating this flow with MSAL Python is not yet available.
218
+
219
+
---
142
220
143
221
You can also see an example of OBO flow implementation in [Node.js and Azure Functions](https://github.com/Azure-Samples/ms-identity-nodejs-webapi-onbehalfof-azurefunctions/blob/master/MiddleTierAPI/MyHttpTrigger/index.js#L61).
0 commit comments