コード例 #1
0
        public static MsalAuthenticationProvider GetInstance(IConfidentialClientApplication application, string[] scopes)
        {
            if (_singleton == null)
            {
                _singleton = new MsalAuthenticationProvider(application, scopes);
            }

            return(_singleton);
        }
コード例 #2
0
        private static IAuthenticationProvider CreateAuthorizationProvider(IConfigurationRoot config)
        {
            var tenantId     = config["tenantId"];
            var clientId     = config["applicationId"];
            var clientSecret = config["applicationSecret"];
            var authority    = $"https://login.microsoftonline.com/{config["tenantId"]}/v2.0";

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

            scopes.Add("https://graph.microsoft.com/.default");

            var cca = ConfidentialClientApplicationBuilder.Create(clientId)
                      .WithAuthority(authority)
                      .WithClientSecret(clientSecret)
                      .Build();

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