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
@@ -159,128 +159,6 @@ For a Blazor app based on the Blazor WebAssembly Hosted project template, <xref:
159
159
* The <xref:System.Net.Http.HttpClient.BaseAddress?displayProperty=nameWithType> (`new Uri(builder.HostEnvironment.BaseAddress)`).
160
160
* A URL of the `authorizedUrls` array.
161
161
162
-
### Graph API example
163
-
164
-
In the following example, a named <xref:System.Net.Http.HttpClient> for Graph API is used to obtain a user's mobile phone number to process a call. After adding the Microsoft Graph API `User.Read` permission in the AAD area of the Azure portal, the scope is configured for the named client in the standalone app or *`Client`* app of a hosted Blazor solution.
165
-
166
-
> [!NOTE]
167
-
> The example in this section obtains Graph API data for the user in *component code*. To create user claims from Graph API, see the following resources:
168
-
>
169
-
> *[Customize the user](#customize-the-user) section
$"Form successfully processed at {DateTime.UtcNow}. " +
256
-
$"Mobile Phone: {userInfo.MobilePhone}");
257
-
}
258
-
}
259
-
else
260
-
{
261
-
formStatus = "There was a problem processing the form.";
262
-
Logger.LogError("Token failure");
263
-
}
264
-
}
265
-
266
-
private class CallInfo
267
-
{
268
-
[Required]
269
-
[StringLength(1000, ErrorMessage = "Message too long (1,000 char limit)")]
270
-
public string Message { get; set; }
271
-
}
272
-
273
-
private class UserInfo
274
-
{
275
-
[JsonPropertyName("mobilePhone")]
276
-
public string MobilePhone { get; set; }
277
-
}
278
-
}
279
-
```
280
-
281
-
> [!NOTE]
282
-
> In the preceding example, the developer implements the custom `ICallProcessor` (`CallProcessor`) to queue and then place automated calls.
283
-
284
162
## Typed `HttpClient`
285
163
286
164
A typed client can be defined that handles all of the HTTP and token acquisition concerns within a single class.
@@ -915,134 +793,6 @@ Register the `CustomAccountFactory` for the authentication provider in use. Any
915
793
CustomUserAccount, CustomAccountFactory>();
916
794
```
917
795
918
-
### Customize the user with Graph API claims
919
-
920
-
In the following example, the app creates a mobile phone number claim for the user from Graph API using the <xref:Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteUserAccount>. The app must have the `User.Read` Graph API permission (scope) configured in AAD.
In the following `CustomAccountFactory` (`CustomAccountFactory.cs`), the framework's <xref:Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteUserAccount> represents the user's account. If the app requires a custom user account class that extends <xref:Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteUserAccount>, swap the custom user account class for <xref:Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteUserAccount> in the following code:
logger.LogError("Graph API access token failure: {MESSAGE}",
1017
-
exception.Message);
1018
-
}
1019
-
}
1020
-
1021
-
returninitialUser;
1022
-
}
1023
-
}
1024
-
```
1025
-
1026
-
In `Program.Main` (`Program.cs`), configure the app to use the custom factory. If the app uses a custom user account class that extends <xref:Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteUserAccount>, swap the custom user account class for <xref:Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteUserAccount> in the following code:
The preceding example is for an app that uses AAD authentication with MSAL. Similar patterns exist for OIDC and API authentication. For more information, see the examples at the end of the [Customize the user with a payload claim](#customize-the-user-with-a-payload-claim) section.
1045
-
1046
796
### AAD security groups and roles with a custom user account class
1047
797
1048
798
For an additional example that works with AAD security groups and AAD Administrator Roles and a custom user account class, see <xref:blazor/security/webassembly/aad-groups-roles>.
@@ -1283,4 +1033,5 @@ For more information, see <xref:grpc/browser>.
1283
1033
1284
1034
## Additional resources
1285
1035
1036
+
*<xref:blazor/security/webassembly/graph-api>
1286
1037
*[`HttpClient` and `HttpRequestMessage` with Fetch API request options](xref:blazor/call-web-api#httpclient-and-httprequestmessage-with-fetch-api-request-options)
0 commit comments