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/scenario-web-app-call-api-acquire-token.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ ms.custom: aaddev
19
19
20
20
You've built your client application object. Now, you'll use it to acquire a token to call a web API. In ASP.NET or ASP.NET Core, calling a web API is done in the controller:
21
21
22
-
- Get a token for the web API by using the token cache. To get this token, you call the MSAL `AcquireTokenSilent` method (or the equivalent in Microsoft.IdentityWeb).
22
+
- Get a token for the web API by using the token cache. To get this token, you call the MSAL `AcquireTokenSilent` method (or the equivalent in Microsoft.Identity.Web).
23
23
- Call the protected API, passing the access token to it as a parameter.
Copy file name to clipboardExpand all lines: articles/active-directory/develop/scenario-web-app-sign-user-app-configuration.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -203,18 +203,18 @@ The initialization code is different depending on the platform. For ASP.NET Core
203
203
204
204
# [ASP.NET Core](#tab/aspnetcore)
205
205
206
-
In ASP.NET Core web apps (and web APIs), the application is protected because you have a `[Authorize]` attribute on the controllers or the controller actions. This attribute checks that the user is authenticated. The code that's initializing the application is in the `Startup.cs` file.
206
+
In ASP.NET Core web apps (and web APIs), the application is protected because you have a `[Authorize]` attribute on the controllers or the controller actions. This attribute checks that the user is authenticated. The code that's initializing the application is in the *Startup.cs* file.
207
207
208
208
To add authentication with the Microsoft identity platform (formerly Azure AD v2.0), you'll need to add the following code. The comments in the code should be self-explanatory.
209
209
210
210
> [!NOTE]
211
-
> If you start your project with the default ASP.NET Core web project within Visual studioor by using `dotnet new mvc --auth SingleAuth`or`dotnet new webapp --auth SingleAuth`, you'll see code like the following: `services.AddAuthentication(AzureADDefaults.AuthenticationScheme).AddAzureAD(options => Configuration.Bind("AzureAd", options));`.
211
+
> If you start your project with the default ASP.NET Core web project within Visual Studioor by using `dotnet new mvc --auth SingleAuth`or`dotnet new webapp --auth SingleAuth`, you'll see code like the following: `services.AddAuthentication(AzureADDefaults.AuthenticationScheme).AddAzureAD(options => Configuration.Bind("AzureAd", options));`.
212
212
>
213
-
> This code uses the legacy **Microsoft.AspNetCore.Authentication.AzureAD.UI** NuGet package which is used to create an Azure AD v1.0 application. This article explains how to create a Microsoft identity platform (Azure AD v2.0) application, inwhich that codeis replaced
213
+
> This code uses the legacy **Microsoft.AspNetCore.Authentication.AzureAD.UI** NuGet package which is used to create an Azure AD v1.0 application. This article explains how to create a Microsoft identity platform (Azure AD v2.0) applicationwhich replaces that code.
214
214
215
-
1. Add the following NuGet packages [Microsoft.Identity.Web](https://www.nuget.org/packages/Microsoft.Identity.Web) and [Microsoft.Identity.Web.UI](https://www.nuget.org/packages/Microsoft.Identity.Web.UI) to your project. You can also remove the Microsoft.AspNetCore.Authentication.AzureAD.UI NuGet package if it's present.
215
+
1. Add the [Microsoft.Identity.Web](https://www.nuget.org/packages/Microsoft.Identity.Web) and [Microsoft.Identity.Web.UI](https://www.nuget.org/packages/Microsoft.Identity.Web.UI) NuGet packages to your project. Remove the Microsoft.AspNetCore.Authentication.AzureAD.UI NuGet package if it's present.
216
216
217
-
2. Update the code in`ConfigureServices` so that it uses the `AddSignIn`andthe `AddMicrosoftIdentityUI` methods
217
+
2. Update the code in`ConfigureServices` so that it uses the `AddSignIn`and`AddMicrosoftIdentityUI` methods.
218
218
219
219
```c#
220
220
public class Startup
@@ -234,7 +234,7 @@ To add authentication with the Microsoft identity platform (formerly Azure AD v2
234
234
}).AddMicrosoftIdentityUI();
235
235
```
236
236
237
-
3. Make sure that the `Configure` method in`Startup.cs` enables authentication by a call to `app.UseAuthentication();`
237
+
3. In the `Configure` method in*Startup.cs*, enable authentication with a call to `app.UseAuthentication();`
238
238
239
239
```c#
240
240
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -248,18 +248,18 @@ To add authentication with the Microsoft identity platform (formerly Azure AD v2
248
248
```
249
249
250
250
In the code above:
251
-
-the`AddSignIn` extension method is defined in**Microsoft.Identity.Web**. It:
251
+
-The`AddSignIn` extension method is defined in**Microsoft.Identity.Web**. It:
252
252
- Adds the authentication service.
253
253
- Configures options to read the configuration file (here from the "AzureAD" section)
254
-
- Configures the OpenID Connect options so that the used authority is the Microsoft identity platform (formerly Azure AD v2.0) endpoint.
254
+
- Configures the OpenID Connect options so that the authority is the Microsoft identity platform endpoint.
255
255
- Validates the issuer of the token.
256
256
- Ensures that the claims corresponding to name are mapped from the `preferred_username` claim in the ID token.
257
257
258
258
- In addition to the configuration object, you can specify the name of the configuration section when calling `AddSignIn`. By default, it's `AzureAd`.
259
259
260
-
-`AddSignIn` has other parameters for advanced scenarios. For instance, tracing OpenId Connect middleware events can help you troubleshoot your web application if authentication doesn't work. Setting the optional parameter `subscribeToOpenIdConnectMiddlewareDiagnosticsEvents` to `true` will show you how information gets elaborated by the set of ASP.NET Core middleware as it progresses from the HTTP response to the identity of the user in `HttpContext.User`.
260
+
-`AddSignIn` has other parameters for advanced scenarios. For example, tracing OpenID Connect middleware events can help you troubleshoot your web application if authentication doesn't work. Setting the optional parameter `subscribeToOpenIdConnectMiddlewareDiagnosticsEvents` to `true` will show you how information is processed by the set of ASP.NET Core middleware as it progresses from the HTTP response to the identity of the user in `HttpContext.User`.
261
261
262
-
- The `AddMicrosoftIdentityUI` extension method is defined in**Microsoft.Identity.Web.UI**. It provides some default controller to handle sign-out
262
+
- The `AddMicrosoftIdentityUI` extension method is defined in**Microsoft.Identity.Web.UI**. It provides a default controller to handle sign-out.
0 commit comments