Beispiel #1
0
        public AuthenticatedHttpClient(string baseAddress, ClientTokenProvider tokenProvider)
        {
            var authenticationHandler = new AuthenticationHandler(tokenProvider);

            this.HttpClient = new HttpClient(authenticationHandler)
            {
                BaseAddress = new Uri(baseAddress)
            };
        }
        protected override void BeginProcessing()
        {
            if (this.TokenProvider == null)
            {
                this.TokenProvider = new ClientTokenProvider(DefaultClientId, DefaultAuthority, DefaultTenantId, DefaultRedirectUri, DefaultScopes);
            }

            if (string.IsNullOrEmpty(this.BackendBaseAddress))
            {
                this.BackendBaseAddress = DefaultBackendBaseAddress;
            }

            var authHttpClient = new AuthenticatedHttpClient(DefaultBackendBaseAddress, this.TokenProvider);

            this.apiClient = new ApiClient(new HttpClientFactory(authHttpClient.HttpClient));
        }
Beispiel #3
0
        protected override void ProcessRecord()
        {
            ClientTokenProvider result;

            if (this.Default)
            {
                result = new ClientTokenProvider(
                    BaseSafeSecretCommand.DefaultClientId,
                    BaseSafeSecretCommand.DefaultAuthority,
                    BaseSafeSecretCommand.DefaultTenantId,
                    BaseSafeSecretCommand.DefaultRedirectUri,
                    BaseSafeSecretCommand.DefaultScopes);
            }
            else
            {
                result = new ClientTokenProvider(this.ClientId, this.Authority, this.TenantId, this.RedirectUri, this.Scopes);
            }

            WriteObject(result);
        }
 public AuthenticationHandler(HttpMessageHandler innerHandler, ClientTokenProvider tokenProvider)
     : base(innerHandler)
 {
     this.tokenProvider = tokenProvider ?? throw new ArgumentNullException(nameof(tokenProvider));
 }
 public AuthenticationHandler(ClientTokenProvider tokenProvider)
     : this(new HttpClientHandler(), tokenProvider)
 {
 }