# 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}";
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dev.ucommerce.net/readme/headless/headless-api-authentication/token-endpoint-authorization-header.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
