# Token endpoint - Authorization Header

The `/api/v1/oauth/token` endpoint uses the Basic HTTP Authentication scheme (as defined in [rfc7617](https://datatracker.ietf.org/doc/html/rfc7617)).

The format for the header is: `Basic : <credentials encoded as base64>`.  A step-by-step to formatting in .NET:

* Take the `clientId` and the `secret` and format them as delimited by a colon (:)

```csharp
string credentials = $"{clientId}:{clientSecret}";
```

* Next, encode this string as a base64 string

```csharp
byte[] credentialsByteData = Encoding.GetEncoding("iso-8859-1").GetBytes(credentials);
string base64Credentials = Convert.ToBase64String(credentialsByteData);
```

* Lastly, format it to include the "Basic" keyword, followed by the now encoded credentials:

```csharp
return $"Basic {base64Credentials}";
```

Put together in a method that can be reused for both token and refresh token requests:

```csharp
public string GenerateBasicAuthorizationHeaderValue(string clientId, string clientSecret)
{
    string credentials = $"{clientId}:{clientSecret}";
    byte[] credentialsByteData = Encoding.GetEncoding("iso-8859-1").GetBytes(credentials);
    string base64Credentials = Convert.ToBase64String(credentialsByteData);
    return $"Basic {base64Credentials}";
}
```
