-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBasicToken.cs
More file actions
42 lines (36 loc) · 1.24 KB
/
BasicToken.cs
File metadata and controls
42 lines (36 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// <auto-generated>
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace DocSpring.Client.Client
{
/// <summary>
/// A token constructed from a username and password.
/// </summary>
public class BasicToken : TokenBase
{
private string _username;
private string _password;
/// <summary>
/// Constructs a BasicToken object.
/// </summary>
/// <param name="username"></param>
/// <param name="password"></param>
/// <param name="timeout"></param>
public BasicToken(string username, string password, TimeSpan? timeout = null) : base(timeout)
{
_username = username;
_password = password;
}
/// <summary>
/// Places the token in the header.
/// </summary>
/// <param name="request"></param>
/// <param name="headerName"></param>
public virtual void UseInHeader(global::System.Net.Http.HttpRequestMessage request, string headerName)
{
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", DocSpring.Client.Client.ClientUtils.Base64Encode(_username + ":" + _password));
}
}
}