GenerateAuthorizationParameter() public method

Generates a string with the contents for the HTTP authorization header.
public GenerateAuthorizationParameter ( ) : string
return string
Ejemplo n.º 1
0
        /// <summary>
        /// Sets the authorization information to be sent in all requests.
        /// </summary>
        /// <param name="auth">The authorization data.</param>
        /// <returns>The current <see cref="Client"/> instace.</returns>
        public Client SetAuthorization(Authorization auth)
        {
            Authorization = auth ?? new Authorization();
            string authorizationHeaderValue = Authorization.GenerateAuthorizationParameter();

            if (http.DefaultRequestHeaders.Contains("Authorization"))
            {
                http.DefaultRequestHeaders.Remove("Authorization");
            }
            http.DefaultRequestHeaders.Add("Authorization", authorizationHeaderValue);
            return(this);
        }