/// <summary>
 /// Modifies the request to ensure that the authentication requirements are met.
 /// </summary>
 /// <param name="client">Client executing this request</param>
 /// <param name="request">Request to authenticate</param>
 /// <param name="credentials">The credentials used for the authentication</param>
 /// <returns>The task the authentication is performed on</returns>
 public override async Task PreAuthenticate(IHttpClient client, IHttpRequestMessage request, ICredentials credentials)
 {
     // When the authorization failed or when the Authorization header is missing, we're just adding it (again) with the
     // new AccessToken.
     var authHeader = $"{_tokenType} {await Client.GetCurrentToken()}";
     request.SetAuthorizationHeader(AuthHeader.Www, authHeader);
 }
예제 #2
0
        /// <summary>
        /// Modifies the request to ensure that the authentication requirements are met.
        /// </summary>
        /// <param name="client">Client executing this request</param>
        /// <param name="request">Request to authenticate</param>
        /// <param name="credentials">The credentials used for the authentication</param>
        /// <returns>The task the authentication is performed on</returns>
        public override async Task PreAuthenticate(IHttpClient client, IHttpRequestMessage request, ICredentials credentials)
        {
            // When the authorization failed or when the Authorization header is missing, we're just adding it (again) with the
            // new AccessToken.
            var authHeader = $"{_tokenType} {await Client.GetCurrentToken().ConfigureAwait(false)}";

            request.SetAuthorizationHeader(AuthHeader.Www, authHeader);
        }
 /// <summary>
 /// Modifies the request to ensure that the authentication requirements are met.
 /// </summary>
 /// <param name="client">Client executing this request</param>
 /// <param name="request">Request to authenticate</param>
 /// <param name="credentials">The credentials used for the authentication</param>
 /// <returns>The task the authentication is performed on</returns>
 public Task PreAuthenticate(IHttpClient client, IHttpRequestMessage request, ICredentials credentials)
 {
     return(Task.Factory.StartNew(() =>
     {
         if (!CanPreAuthenticate(client, request, credentials))
         {
             throw new InvalidOperationException();
         }
         var authHeaderValue = $"{AuthenticationMethod} {_authToken}";
         request.SetAuthorizationHeader(_authHeader, authHeaderValue);
     }));
 }
        /// <summary>
        /// Modifies the request to ensure that the authentication requirements are met.
        /// </summary>
        /// <param name="client">Client executing this request</param>
        /// <param name="request">Request to authenticate</param>
        /// <param name="credentials">The credentials used for the authentication</param>
        /// <returns>The task the authentication is performed on</returns>
        public async Task PreAuthenticate(IHttpClient client, IHttpRequestMessage request, ICredentials credentials)
        {
            if (!CanPreAuthenticate(client, request, credentials))
            {
                throw new InvalidOperationException();
            }

            var digestHeader = await GetDigestHeader(client, request, _authCredential).ConfigureAwait(false);

            var authHeaderValue = $"{AuthenticationMethod} {digestHeader}";

            request.SetAuthorizationHeader(_authHeader, authHeaderValue);
        }
예제 #5
0
        /// <summary>
        /// Modifies the request to ensure that the authentication requirements are met.
        /// </summary>
        /// <param name="client">Client executing this request</param>
        /// <param name="request">Request to authenticate</param>
        /// <param name="credentials">The credentials used for the authentication</param>
        /// <returns>The task the authentication is performed on</returns>
        public Task PreAuthenticate(IHttpClient client, IHttpRequestMessage request, ICredentials credentials)
        {
            if (!HasAuthorizationToken)
            {
                throw new InvalidOperationException();
            }

            var authHeaderValue = $"{AuthenticationMethod} {_authToken}";

            request.SetAuthorizationHeader(_authHeader, authHeaderValue);

#if ASYNC_PCL
            return(Task.FromResult(0));
#else
            return(new Task(() => { }));
#endif
        }
        /// <summary>
        /// Modifies the request to ensure that the authentication requirements are met.
        /// </summary>
        /// <param name="client">Client executing this request</param>
        /// <param name="request">Request to authenticate</param>
        /// <param name="credentials">The credentials used for the authentication</param>
        /// <returns>The task the authentication is performed on</returns>
        public async Task PreAuthenticate(IHttpClient client, IHttpRequestMessage request, ICredentials credentials)
        {
            if (!CanPreAuthenticate(client, request, credentials))
                throw new InvalidOperationException();

            var digestHeader = await GetDigestHeader(client, request, _authCredential);
            var authHeaderValue = $"{AuthenticationMethod} {digestHeader}";
            request.SetAuthorizationHeader(_authHeader, authHeaderValue);
        }
        /// <summary>
        /// Modifies the request to ensure that the authentication requirements are met.
        /// </summary>
        /// <param name="client">Client executing this request</param>
        /// <param name="request">Request to authenticate</param>
        /// <param name="credentials">The credentials used for the authentication</param>
        /// <returns>The task the authentication is performed on</returns>
        public Task PreAuthenticate(IHttpClient client, IHttpRequestMessage request, ICredentials credentials)
        {
            return Task.Factory.StartNew(() =>
            {
                if (!CanPreAuthenticate(client, request, credentials))
                {
                    throw new InvalidOperationException();
                }

                var authHeaderValue = $"{AuthenticationMethod} {_authToken}";
                request.SetAuthorizationHeader(_authHeader, authHeaderValue);
            });
        }
        /// <summary>
        /// Modifies the request to ensure that the authentication requirements are met.
        /// </summary>
        /// <param name="client">Client executing this request</param>
        /// <param name="request">Request to authenticate</param>
        /// <param name="credentials">The credentials used for the authentication</param>
        /// <returns>The task the authentication is performed on</returns>
        public Task PreAuthenticate(IHttpClient client, IHttpRequestMessage request, ICredentials credentials)
        {
            if (!HasAuthorizationToken)
            {
                throw new InvalidOperationException();
            }

            var authHeaderValue = $"{AuthenticationMethod} {_authToken}";
            request.SetAuthorizationHeader(_authHeader, authHeaderValue);

#if ASYNC_PCL
            return Task.FromResult(0);
#else
            return new Task(() => { });
#endif
        }