I'm trying to integrate MSAL into a .NET Maui app and I'm following the following article from Microsoft:
Add authentication to your .NET MAUI app
They ask you to install the Microsoft.Identity.Client
Nuget package which I did and the next part of the article is to create a function to request the authentication token:
public async Task<AuthenticationToken> GetAuthenticationToken()
and this is what it is supposed to return:
return new AuthenticationToken
{
DisplayName = result?.Account?.Username ?? "",
ExpiresOn = result?.ExpiresOn ?? DateTimeOffset.MinValue,
Token = result?.AccessToken ?? "",
UserId = result?.Account?.Username ?? ""
};
I've adjusted the function and added any missing libaries but for the AuthenticationToken
, the only option it offers is to install Microsoft.AspNetCore.Authentication.Abstractions
.
Surely the MSAL library should contain an AuthenticationToken
class without the need of having to install some Nuget package from ASP.NET Core
.
Anyone has any suggestions? Is the class called something else?
Thanks
This AuthenticationToken
is from the Microsoft.Datasync.Client
nuget.
The docs you've linked tell you to add these using
statements:
using Microsoft.Datasync.Client;
using Microsoft.Identity.Client;
using System.Diagnostics;
The first using
is enough to have AuthenticationToken
in scope.