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
Because ID tokens and access tokens can persist across login attempts, clear browser cookies using the browser's developer console after every update to:
3
+
### Cookies and site data
4
4
5
-
* The app's authentication code or configuration settings.
6
-
* The app's configuration OIDC-compliant provider (for example, Azure Active Directory).
5
+
Cookies and site data can persist across app updates and interfere with testing and troubleshooting. Clear the following when making app code changes, user account changes with the provider, or provider app configuration changes:
6
+
7
+
* User sign-in cookies
8
+
* App cookies
9
+
* Cached and stored site data
10
+
11
+
One approach to prevent lingering cookies and site data from interfering with testing and troubleshooting is to:
12
+
13
+
* Use a browser for testing that you can configure to delete all cookie and site data each time the browser is closed.
14
+
* Close the browser between any change to the app, test user, or provider configuration.
15
+
16
+
### Run the Server app
17
+
18
+
When testing and troubleshooting a hosted Blazor app, make sure that you're running the app from the **Server** project. For example in Visual Studio, confirm that the Server project is highlighted in **Solution Explorer** before you start the app with any of the following approaches:
19
+
20
+
* Select the **Run** button.
21
+
* Use **Debug** > **Start Debugging** from the menu.
**Server API app* Application ID (Client ID) (for example, `11111111-1111-1111-1111-111111111111`)
55
+
* App ID URI (for example, `https://contoso.onmicrosoft.com/11111111-1111-1111-1111-111111111111`, `api://11111111-1111-1111-1111-111111111111`, or the custom value that you provided)
55
56
* Directory ID (Tenant ID) (for example, `222222222-2222-2222-2222-222222222222`)
56
57
**Server API app* App ID URI (for example, `https://contoso.onmicrosoft.com/11111111-1111-1111-1111-111111111111`, the Azure portal might default the value to the Client ID)
57
58
* Default scope (for example, `API.Access`)
@@ -100,11 +101,14 @@ Record the following information:
100
101
Replace the placeholders in the following command with the information recorded earlier and execute the command in a command shell:
101
102
102
103
```dotnetcli
103
-
dotnet new blazorwasm -au IndividualB2C --aad-b2c-instance "{AAD B2C INSTANCE}" --api-client-id "{SERVER API APP CLIENT ID}" --app-id-uri "{APP ID URI}" --client-id "{CLIENT APP CLIENT ID}" --default-scope "{DEFAULT SCOPE}" --domain "{DOMAIN}" -ho -ssp "{SIGN UP OR SIGN IN POLICY}" --tenant-id "{TENANT ID}"
104
+
dotnet new blazorwasm -au IndividualB2C --aad-b2c-instance "{AAD B2C INSTANCE}" --api-client-id "{SERVER API APP CLIENT ID}" --app-id-uri "{SERVER API APP ID URI}" --client-id "{CLIENT APP CLIENT ID}" --default-scope "{DEFAULT SCOPE}" --domain "{DOMAIN}" -ho -ssp "{SIGN UP OR SIGN IN POLICY}" --tenant-id "{TENANT ID}"
104
105
```
105
106
106
107
To specify the output location, which creates a project folder if it doesn't exist, include the output option in the command with a path (for example, `-o BlazorSample`). The folder name also becomes part of the project's name.
107
108
109
+
> [!NOTE]
110
+
> Pass the App ID URI to the `app-id-uri` option, but note a configuration change might be required in the client app, which is described in the [Access token scopes](#access-token-scopes) section.
111
+
108
112
## Server app configuration
109
113
110
114
*This section pertains to the solution's **Server** app.*
The `AddMsalAuthentication` method accepts a callback to configure the parameters required to authenticate an app. The values required for configuring the app can be obtained from the Azure Portal AAD configuration when you register the app.
229
232
230
-
The Blazor WebAssembly template automatically configures the app to request an access token for a secure API for the default scope provided to the `dotnet new` command (`{APP ID URI}/{DEFAULT SCOPE}`).
233
+
### Access token scopes
231
234
232
235
The default access token scopes represent the list of access token scopes that are:
233
236
@@ -240,11 +243,25 @@ All scopes must belong to the same app per Azure Active Directory rules. Additio
> If the Azure portal provides a scope URI and **the app throws an unhandled exception** when it receives a *401 Unauthorized* response from the API, try using a scope URI that doesn't include the scheme and host. For example, the Azure portal may provide one of the following scope URI formats:
252
+
>
253
+
> *`https://{ORGANIZATION}.onmicrosoft.com/{API CLIENT ID OR CUSTOM VALUE}/{SCOPE NAME}`
254
+
> *`api://{API CLIENT ID OR CUSTOM VALUE}/{SCOPE NAME}`
255
+
>
256
+
> Supply the scope URI without the scheme and host:
**Server API app* Application ID (Client ID) (for example, `11111111-1111-1111-1111-111111111111`)
56
+
* App ID URI (for example, `https://contoso.onmicrosoft.com/11111111-1111-1111-1111-111111111111`, `api://11111111-1111-1111-1111-111111111111`, or the custom value that you provided)
56
57
* Directory ID (Tenant ID) (for example, `222222222-2222-2222-2222-222222222222`)
57
58
* AAD Tenant domain (for example, `contoso.onmicrosoft.com`)
58
59
* Default scope (for example, `API.Access`)
@@ -92,13 +93,13 @@ Record the *Client app* Application ID (Client ID) (for example, `33333333-3333-
92
93
Replace the placeholders in the following command with the information recorded earlier and execute the command in a command shell:
dotnet new blazorwasm -au SingleOrg --api-client-id "{SERVER API APP CLIENT ID}" --app-id-uri "{SERVER API APP ID URI}" --client-id "{CLIENT APP CLIENT ID}" --default-scope "{DEFAULT SCOPE}" --domain "{DOMAIN}" -ho --tenant-id "{TENANT ID}"
96
97
```
97
98
98
99
To specify the output location, which creates a project folder if it doesn't exist, include the output option in the command with a path (for example, `-o BlazorSample`). The folder name also becomes part of the project's name.
99
100
100
101
> [!NOTE]
101
-
> See the [Authentication service support](#Authentication service support) section for an important configuration change to the default access token scope. The value provided by the Blazor WebAssembly template must be manually changed after the *Client app*is created from the template.
102
+
> Pass the App ID URI to the `app-id-uri` option, but note a configuration change might be required in the client app, which is described in the [Access token scopes](#access-token-scopes) section.
102
103
103
104
## Server app configuration
104
105
@@ -207,24 +208,20 @@ Support for authenticating users is registered in the service container with the
207
208
208
209
*Program.cs*:
209
210
210
-
When the *Client app* is generated, the default access token scope is of the format `api://{SERVER API APP CLIENT ID}/{DEFAULT SCOPE}`. **Remove the `api://` portion of the scope value.** This issue will be addressed in a future preview release.
> The default access token scope must be in the format `{SERVER API APP CLIENT ID}/{DEFAULT SCOPE}` (for example, `11111111-1111-1111-1111-111111111111/API.Access`). If a scheme or scheme and host is provided to the scope setting (as shown in the Azure Portal), the *Client app* throws an unhandled exception when it receives a *401 Unauthorized* response from the *Server API app*.
225
-
226
221
The `AddMsalAuthentication` method accepts a callback to configure the parameters required to authenticate an app. The values required for configuring the app can be obtained from the Azure Portal AAD configuration when you register the app.
227
222
223
+
### Access token scopes
224
+
228
225
The default access token scopes represent the list of access token scopes that are:
229
226
230
227
* Included by default in the sign in request.
@@ -236,11 +233,25 @@ All scopes must belong to the same app per Azure Active Directory rules. Additio
> If the Azure portal provides a scope URI and **the app throws an unhandled exception** when it receives a *401 Unauthorized* response from the API, try using a scope URI that doesn't include the scheme and host. For example, the Azure portal may provide one of the following scope URI formats:
242
+
>
243
+
> *`https://{ORGANIZATION}.onmicrosoft.com/{API CLIENT ID OR CUSTOM VALUE}/{SCOPE NAME}`
244
+
> *`api://{API CLIENT ID OR CUSTOM VALUE}/{SCOPE NAME}`
245
+
>
246
+
> Supply the scope URI without the scheme and host:
Authentication support for standalone apps is offered using Open ID Connect (OIDC). The `AddOidcAuthentication` method accepts a callback to configure the parameters required to authenticate an app using OIDC. The values required for configuring the app can be obtained from the OIDC-compliant IP. Obtain the values when you register the app, which typically occurs in their online portal.
61
61
62
-
### Imports file
62
+
## Access token scopes
63
+
64
+
The Blazor WebAssembly template doesn't automatically configure the app to request an access token for a secure API. To provision a token as part of the sign-in flow, add the scope to the default token scopes of the `OidcProviderOptions`:
> If the Azure portal provides a scope URI and **the app throws an unhandled exception** when it receives a *401 Unauthorized* response from the API, try using a scope URI that doesn't include the scheme and host. For example, the Azure portal may provide one of the following scope URI formats:
76
+
>
77
+
> *`https://{ORGANIZATION}.onmicrosoft.com/{API CLIENT ID OR CUSTOM VALUE}/{SCOPE NAME}`
78
+
> *`api://{API CLIENT ID OR CUSTOM VALUE}/{SCOPE NAME}`
79
+
>
80
+
> Supply the scope URI without the scheme and host:
The `AddMsalAuthentication` method accepts a callback to configure the parameters required to authenticate an app. The values required for configuring the app can be obtained from the Azure Portal AAD configuration when you register the app.
84
84
85
+
## Access token scopes
86
+
85
87
The Blazor WebAssembly template doesn't automatically configure the app to request an access token for a secure API. To provision a token as part of the sign-in flow, add the scope to the default access token scopes of the `MsalProviderOptions`:
> If the Azure portal provides a scope URI and **the app throws an unhandled exception** when it receives a *401 Unauthorized* response from the API, try using a scope URI that doesn't include the scheme and host. For example, the Azure portal may provide one of the following scope URI formats:
99
+
>
100
+
> *`https://{ORGANIZATION}.onmicrosoft.com/{API CLIENT ID OR CUSTOM VALUE}/{SCOPE NAME}`
101
+
> *`api://{API CLIENT ID OR CUSTOM VALUE}/{SCOPE NAME}`
102
+
>
103
+
> Supply the scope URI without the scheme and host:
The `AddMsalAuthentication` method accepts a callback to configure the parameters required to authenticate an app. The values required for configuring the app can be obtained from the Azure Portal AAD configuration when you register the app.
83
83
84
+
## Access token scopes
85
+
84
86
The Blazor WebAssembly template doesn't automatically configure the app to request an access token for a secure API. To provision a token as part of the sign-in flow, add the scope to the default access token scopes of the `MsalProviderOptions`:
> The default access token scope must be in the format `{SERVER API APP CLIENT ID}/{DEFAULT SCOPE}` (for example, `11111111-1111-1111-1111-111111111111/API.Access`). If a scheme or scheme and host is provided to the scope setting (as shown in the Azure Portal), the *Client app* throws an unhandled exception when it receives a *401 Unauthorized* response from the *Server API app*.
97
-
98
-
### Imports file
97
+
> If the Azure portal provides a scope URI and **the app throws an unhandled exception** when it receives a *401 Unauthorized* response from the API, try using a scope URI that doesn't include the scheme and host. For example, the Azure portal may provide one of the following scope URI formats:
98
+
>
99
+
> *`https://{ORGANIZATION}.onmicrosoft.com/{API CLIENT ID OR CUSTOM VALUE}/{SCOPE NAME}`
100
+
> *`api://{API CLIENT ID OR CUSTOM VALUE}/{SCOPE NAME}`
101
+
>
102
+
> Supply the scope URI without the scheme and host:
The `AddMsalAuthentication` method accepts a callback to configure the parameters required to authenticate an app. The values required for configuring the app can be obtained from the Microsoft Accounts configuration when you register the app.
85
85
86
-
### Imports file
86
+
## Access token scopes
87
+
88
+
The Blazor WebAssembly template doesn't automatically configure the app to request an access token for a secure API. To provision a token as part of the sign-in flow, add the scope to the default access token scopes of the `MsalProviderOptions`:
> If the Azure portal provides a scope URI and **the app throws an unhandled exception** when it receives a *401 Unauthorized* response from the API, try using a scope URI that doesn't include the scheme and host. For example, the Azure portal may provide one of the following scope URI formats:
100
+
>
101
+
> *`https://{ORGANIZATION}.onmicrosoft.com/{API CLIENT ID OR CUSTOM VALUE}/{SCOPE NAME}`
102
+
> *`api://{API CLIENT ID OR CUSTOM VALUE}/{SCOPE NAME}`
103
+
>
104
+
> Supply the scope URI without the scheme and host:
0 commit comments