Skip to content

Commit

Permalink
Blazor Graph code NIT (#27884)
Browse files Browse the repository at this point in the history
  • Loading branch information
guardrex authored Dec 11, 2022
1 parent 076fe52 commit 175ac1f
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions aspnetcore/blazor/security/webassembly/graph-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ The following `GraphExample` component uses an injected `GraphServiceClient` to
<h1>Microsoft Graph Component Example</h1>
@if (user is not null && !string.IsNullOrEmpty(user.MobilePhone))
@if (!string.IsNullOrEmpty(user?.MobilePhone))
{
<p>Mobile Phone: @user.MobilePhone</p>
}
Expand Down Expand Up @@ -442,27 +442,22 @@ In the following `GraphExample` component, an <xref:System.Net.Http.HttpClient>
<h1>Microsoft Graph Component Example</h1>
@if (!string.IsNullOrEmpty(mobilePhone))
@if (!string.IsNullOrEmpty(userInfo?.MobilePhone))
{
<p>Mobile Phone: @mobilePhone</p>
<p>Mobile Phone: @userInfo.MobilePhone</p>
}
@code {
private string? mobilePhone;
private UserInfo? userInfo;
protected override async Task OnInitializedAsync()
{
try
{
var client = ClientFactory.CreateClient("GraphAPI");
var userInfo = await client.GetFromJsonAsync<UserInfo>(
userInfo = await client.GetFromJsonAsync<UserInfo>(
$"{Config.GetSection("MicrosoftGraph")["Version"]}/me");
if (userInfo is not null && !string.IsNullOrEmpty(userInfo.MobilePhone))
{
mobilePhone = userInfo.MobilePhone;
}
}
catch (AccessTokenNotAvailableException exception)
{
Expand Down

0 comments on commit 175ac1f

Please sign in to comment.