Skip to content

Commit a74884e

Browse files
committed
Cover ValidAudiences and ValidAudience
1 parent a4cf7c8 commit a74884e

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

aspnetcore/blazor/security/blazor-web-app-with-entra.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,12 +1198,25 @@ This article and its accompanying sample apps adopt V1 STS tokens. To adopt V2 t
11981198
// Ensure the issuer ends with /v2.0 if using the V2 endpoint
11991199
ValidIssuer = "https://login.microsoftonline.com/{TENANT ID}/v2.0",
12001200
ValidateAudience = true,
1201-
ValidAudience = "{WEB API CLIENT ID}",
1201+
ValidAudiences = new[] { "{WEB API CLIENT ID 1}", "{WEB API CLIENT ID 2}", ... },
12021202
ValidateLifetime = true
12031203
};
12041204
```
12051205
1206-
The `{WEB API CLIENT ID}` placeholder in the preceding example is only the client ID, not the full value passed to the `Audience` property.
1206+
Instead of setting the <xref:Microsoft.IdentityModel.Tokens.TokenValidationParameters.ValidAudiences%2A> property, you can specify a single valid audience with <xref:Microsoft.IdentityModel.Tokens.TokenValidationParameters.ValidAudience%2A>:
1207+
1208+
```csharp
1209+
ValidAudience = "{WEB API CLIENT ID}",
1210+
```
1211+
1212+
The `{WEB API CLIENT ID}` placeholders in the preceding examples are ***only the client IDs***, not the full values passed to the `Audience` property.
1213+
1214+
To supply a collection of valid audiences in an app that [configures Identity from app settings](#supply-configuration-with-the-json-configuration-provider-app-settings), you can use the following code to obtain the valid audiences configuration:
1215+
1216+
```csharp
1217+
ValidAudiences = builder.Configuration.GetSection(
1218+
"Authentication:Schemes:Bearer:ValidAudiences").Get<string[]>(),
1219+
```
12071220
12081221
For more information, see [Access tokens in the Microsoft identity platform: Token formats](/entra/identity-platform/access-tokens#token-formats).
12091222

0 commit comments

Comments
 (0)