コード例 #1
0
        /// <summary>
        /// Creates a new SharedTokenCacheCredential with the specifeid options, which will authenticate users with the specified application.
        /// </summary>
        /// <param name="clientId">The client id of the application to which the users will authenticate</param>
        /// <param name="username">The username of the user to authenticate</param>
        /// TODO: need to link to info on how the application has to be created to authenticate users, for multiple applications
        /// <param name="options">The client options for the newly created SharedTokenCacheCredential</param>
        public SharedTokenCacheCredential(string clientId, string username, SharedTokenCacheCredentialOptions options)
        {
            _clientId = clientId ?? throw new ArgumentNullException(nameof(clientId));

            options ??= new SharedTokenCacheCredentialOptions();

            _username = username;

            HttpPipeline pipeline = HttpPipelineBuilder.Build(options);

            _pubApp = PublicClientApplicationBuilder.Create(_clientId).WithHttpClientFactory(new HttpPipelineClientFactory(pipeline)).Build();

            _cacheReader = new MsalCacheReader(_pubApp.UserTokenCache, options.CacheFilePath, options.CacheAccessRetryCount, options.CacheAccessRetryDelay);
        }
コード例 #2
0
        /// <summary>
        /// Creates a new SharedTokenCacheCredential with the specifeid options, which will authenticate users with the specified application.
        /// </summary>
        /// <param name="clientId">The client id of the application to which the users will authenticate</param>
        /// <param name="username">The username of the user to authenticate</param>
        /// TODO: need to link to info on how the application has to be created to authenticate users, for multiple applications
        /// <param name="options">The client options for the newly created SharedTokenCacheCredential</param>
        public SharedTokenCacheCredential(string clientId, string username, SharedTokenCacheCredentialOptions options)
        {
            _clientId = clientId ?? Constants.DeveloperSignOnClientId;

            options ??= new SharedTokenCacheCredentialOptions();

            _username = username;

            HttpPipeline pipeline = HttpPipelineBuilder.Build(options);

            _pubApp = PublicClientApplicationBuilder.Create(_clientId).WithHttpClientFactory(new HttpPipelineClientFactory(pipeline)).Build();

            _cacheReader = new MsalCacheReader(_pubApp.UserTokenCache, options.CacheFilePath, options.CacheAccessRetryCount, options.CacheAccessRetryDelay);

            _account = new Lazy <Task <IAccount> >(GetAccountAsync);
        }
コード例 #3
0
 /// <summary>
 /// Creates a new <see cref="SharedTokenCacheCredential"/> which will authenticate users signed in through developer tools supporting Azure single sign on.
 /// </summary>
 /// <param name="options">The client options for the newly created <see cref="SharedTokenCacheCredential"/></param>
 public SharedTokenCacheCredential(SharedTokenCacheCredentialOptions options)
     : this(options?.TenantId, options?.Username, options, null, null)
 {
 }
 /// <summary>
 /// Creates a new <see cref="SharedTokenCacheCredential"/> which will authenticate users signed in through developer tools supporting Azure single sign on.
 /// </summary>
 /// <param name="options">The client options for the newly created <see cref="SharedTokenCacheCredential"/></param>
 public SharedTokenCacheCredential(SharedTokenCacheCredentialOptions options)
     : this(options?.TenantId, options?.Username, CredentialPipeline.GetInstance(options))
 {
 }