Skip to content

MSAL.NET 2.x to MSAL.NET 3.x

Jean-Marc Prieur edited this page Mar 26, 2019 · 20 revisions

This page explains how to change the code to move from the MSAL 2.x to MSAL 3.x

IEnumerable<string> scopes;
IAccount account;
string authority;
bool forceRefresh;

ClientApplicationBase

AcquireTokenSilent

Used to acquire an access token from the user cache, and refresh it if needed

Instead of use
app.AcquireTokenSilentAsync(scopes,
                            account)
app.AcquireTokenSilent(scopes,
                       account)   
   .ExecuteAsync();
app.AcquireTokenSilentAsync(scopes,
                            account, 
                            authority,
                            forceRefresh)
app.AcquireTokenSilent(scopes, account)
   .WithAuthority(authority)
   .WithForceRefresh(forceRefresh)    
   .ExecuteAsync();

PublicClientApplication

Constructors of PublicClientApplication

Instead of use
app=new PublicClientApplication(clientId);
app=PublicClientApplicationBuilder
    .Create(clientId)
    .Build();
app=new PublicClientApplication(clientId,
                                authority);
app=PublicClientApplicationBuilder
   .Create(clientId)
   .WithAuthority(authority)
   .Build();

Getting started with MSAL.NET

Acquiring tokens

Desktop/Mobile apps

Web Apps / Web APIs / daemon apps

Advanced topics

News

FAQ

Other resources

Clone this wiki locally