Exemplo n.º 1
0
        public static MsalAuthenticationProvider GetInstance(IPublicClientApplication clientApplication, string[] scopes, string username, SecureString password)
        {
            if (_singleton == null)
            {
                _singleton = new MsalAuthenticationProvider(clientApplication, scopes, username, password);
            }

            return(_singleton);
        }
Exemplo n.º 2
0
        private static IAuthenticationProvider CreateAuthorizationProvider(IConfigurationRoot config, string userName, SecureString userPassword)
        {
            var clientId  = config["applicationId"];
            var authority = $"https://login.microsoftonline.com/{config["tenantId"]}/v2.0";

            List <string> scopes = new List <string>();

            scopes.Add("User.Read");
            scopes.Add("Mail.Read");

            var cca = PublicClientApplicationBuilder.Create(clientId)
                      .WithAuthority(authority)
                      .Build();

            return(MsalAuthenticationProvider.GetInstance(cca, scopes.ToArray(), userName, userPassword));
        }