> For the complete documentation index, see [llms.txt](https://developer.esw.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.esw.com/getting-started/get-started-with-esw/readme-1/publish-your-docs.md).

# Access Tokens

Request OAuth 2.0 access tokens from the ESW **Security Token Service (STS)**.

Most integrations use:

* `grant_type=client_credentials`
* one or more space-separated `scope` values

### Token endpoint

Send a `POST` to:

`https://security-sts.<environment>.eshopworld.com/connect/token`

{% hint style="info" icon="brackets-curly" %}
STS expects `application/x-www-form-urlencoded` body parameters.
{% endhint %}

### Parameters

Include these fields in the request body:

* `grant_type`: OAuth 2.0 grant type. Use `client_credentials`.
* `scope`: Space-separated scopes. Example: `checkout.preorder.api.all`, `pricing.advisor.api.all`
* `client_id`: Client identifier provided by ESW.
* `client_secret`: Client secret provided by ESW.

### Examples

{% tabs %}
{% tab title="cURL" %}

```sh
curl --location --request POST "https://security-sts.<environment>.eshopworld.com/connect/token" \
  --header "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "grant_type=client_credentials" \
  --data-urlencode "scope=<space-separated-scopes>" \
  --data-urlencode "client_id=<client_id>" \
  --data-urlencode "client_secret=<client_secret>"
```

{% endtab %}

{% tab title="C# (RestSharp)" %}

```csharp
var client = new RestClient("https://security-sts.<environment>.eshopworld.com/connect/token");
var request = new RestRequest("", Method.Post);

request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter("grant_type", "client_credentials");
request.AddParameter("scope", "<space-separated-scopes>");
request.AddParameter("client_id", "<client_id>");
request.AddParameter("client_secret", "<client_secret>");

var response = client.Execute(request);
Console.WriteLine(response.Content);
```

{% endtab %}

{% tab title="Java (OkHttp)" %}

```java
OkHttpClient client = new OkHttpClient();

RequestBody body = new FormBody.Builder()
  .add("grant_type", "client_credentials")
  .add("scope", "<space-separated-scopes>")
  .add("client_id", "<client_id>")
  .add("client_secret", "<client_secret>")
  .build();

Request request = new Request.Builder()
  .url("https://security-sts.<environment>.eshopworld.com/connect/token")
  .post(body)
  .build();

Response response = client.newCall(request).execute();
System.out.println(response.body().string());
```

{% endtab %}
{% endtabs %}

See the [Postman collection](/getting-started/get-started-with-esw/readme/postman-collection.md#get-the-postman-collection) for working sandbox examples.

### Access Token Response

STS returns the access token and the token type (usually `Bearer`).

```json
{
    "access_token": "eyJhbGciOiJSUzI1NiIsImtpZC...I6IjQ3NkQ1QzE5QzI1Nzc0NUV",
    "expires_in": 3600,
    "token_type": "Bearer",
    "scope": "checkout.preorder.api.all"
}
```

### Use the token

Send the token on API requests:

```http
Authorization: Bearer <access_token>
```

For the full flow, see [Authentication](/getting-started/get-started-with-esw/readme/quickstart.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://developer.esw.com/getting-started/get-started-with-esw/readme-1/publish-your-docs.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
