Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. private static IAuthenticationProvider CreateAuthorizationProvider(IConfigurationRoot config, string userName, SecureString userPassword)
  2. {
  3.   var clientId = config["applicationId"];
  4.   var authority = $"https://login.microsoftonline.com/{config["tenantId"]}/v2.0";
  5.  
  6.   List<string> scopes = new List<string>();
  7.   scopes.Add("User.Read");
  8.   scopes.Add("User.Read.All");
  9.  
  10.   var cca = PublicClientApplicationBuilder.Create(clientId)
  11.                                           .WithAuthority(authority)
  12.                                           .Build();
  13.   return MsalAuthenticationProvider.GetInstance(cca, scopes.ToArray(), userName, userPassword);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement