All Downloads are FREE. Search and download functionalities are using the official Maven repository.

csharp.libraries.generichost.OAuthToken.mustache Maven / Gradle / Ivy

There is a newer version: 7.6.0
Show newest version
// 
{{partial_header}}
{{#nrt}}
#nullable enable

{{/nrt}}
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace {{packageName}}.{{clientPackage}}
{
    /// 
    /// A token constructed with OAuth.
    /// 
    {{>visibility}} class OAuthToken : TokenBase
    {
        private string _raw;

        /// 
        /// Consturcts an OAuthToken object.
        /// 
        /// 
        /// 
        public OAuthToken(string value, TimeSpan? timeout = null) : base(timeout)
        {
            _raw = value;
        }

        /// 
        /// Places the token in the header.
        /// 
        /// 
        /// 
        public virtual void UseInHeader(System.Net.Http.HttpRequestMessage request, string headerName)
        {
            request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _raw);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy