Esempio n. 1
0
        public AuthorizationHelper(string clientId, string domain)
        {
            if (clientId is null)
            {
                throw new ArgumentNullException(nameof(clientId));
            }
            if (domain is null)
            {
                throw new ArgumentNullException(nameof(domain));
            }

            ClientId  = clientId;
            Authority = string.Format(LoginUrlConstant, domain);
            ApiScopes = new string[] { string.Format(ApiScopesConstant, domain, clientId) };

            // Using MASAL to Get access token and id token
            pca = PublicClientApplicationBuilder
                  .Create(ClientId)
                  .WithAuthority(Authority)
                  .WithDefaultRedirectUri()
                  .Build();

            // Adding cache helper
            TokenCacheHelper.EnableSerialization(pca.UserTokenCache);
        }
Esempio n. 2
0
        public YAuthCliProvider(IOptions <YMicrosoftIdentityOptions> azureAdOptions)
        {
            this.AzureAdOptions = azureAdOptions.Value;

            var authority = string.Format(LoginUrlConstant, AzureAdOptions.Domain);

            // Using MASAL to Get access token and id token
            this.pca = PublicClientApplicationBuilder
                       .Create(AzureAdOptions.ClientId)
                       .WithAuthority(authority)
                       .WithDefaultRedirectUri()
                       .Build();

            // Adding cache helper
            TokenCacheHelper.EnableSerialization(pca.UserTokenCache);
        }