> 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/publish-your-docs.md).

# Access Tokens

Request OAuth 2.0 access tokens from ESW STS using client credentials. Includes required parameters, token endpoint, and code examples

## Credentials

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

{% code title="Send a POST to " expandable="true" %}

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

{% endcode %}

{% @code-walkthrough/alert-block title="" message="STS expects `application/x-www-form-urlencoded` body parameters" type="warning" %}

### 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 %}

### Scopes

{% code title="client\_id" expandable="true" %}

```
gocas.client
```

{% endcode %}

<details open>

<summary>Scopes</summary>

| Allowed Scopes                                 | Description                                     |
| ---------------------------------------------- | ----------------------------------------------- |
| checkout.preorder.api.all                      | Access to PreOrder requests to the Checkout API |
| logistics.catalog.api.upload                   | Upload access to Catalog API                    |
| logistics.package.api.all                      | Full access to Package API                      |
| logistics.returns.api.all                      | Full Access for Returns API                     |
| order.transaction.create.api.all               | Scope to access the order create actions        |
| order.transaction.get.api.all                  | Scope to access the Get Order                   |
| order.transaction.update.api.all               | Scope to access the order update actions        |
| pricing.advisor.api.all                        | Grants full access to Pricing Advisor           |
| order.transaction.update.api.all               | Scope to access the order update actions        |
| order.transaction.cancel.api.all               | Scope to access the Cancel actions              |
| order.transaction.allocation.api.all           | Scope required to access the Order Allocation   |
| logistics.inventory.cart.availability.api.read | Scope required to access Inventory API          |

</details>

{% tabs %}
{% tab title="Sandbox" %}
{% code expandable="true" %}

```http
curl --location --request POST "https://security-sts.sandbox.eshopworld.com/connect/token" \
  --header "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "grant_type=client_credentials" \
  --data-urlencode "scope=checkout.preorder.api.all" \
  --data-urlencode "client_id=gocas.client" \
  --data-urlencode "client_secret=<client_secret>"
```

{% endcode %}
{% 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
