---
title: "AuthenticationTokenProvider class"
slug: "authenticationtokenprovider-class"
abstract: "Overview of the AuthenticationTokenProvider class used to support authentication and tokens in Commerce Connect APIs."
---
# AuthenticationTokenProvider class

To support authentication by using tokens in all of the Commerce Connect APIs, we have introduced an `AuthenticationTokenProvider` class. It consists of an interface defined in the `Sitecore.Commerce.Config` file and a default implementation that always returns `NULL`, meaning no token is provided.

The `Sitecore.Commerce.config` file defines the following authentication provider and `AuthenticationToken` entity configuration:

```xml
<authenticationTokenProvider type="Sitecore.Commerce.Providers.AuthenticationTokenProvider, Sitecore.Commerce.Connect.Core" singleInstance="true"/>
<commerce.Entities>
<AuthenticationToken type="Sitecore.Commerce.Entities.AuthenticationToken, Sitecore.Commerce.Connect.Core" />
</commerce.Entities>

```

![The IAuthenticationTokenProvider interface and AuthenticationTokenProvider class diagrams.](https://doc.sitecore.com/api/markdown-image/xp/en/developers/102/sitecore-experience-commerce/images/03000006.png)

| Name | Description |
| --- | --- |
| **GetToken** | Must return the token if one is required. |

The introduction of the provider centralizes the logic of providing the Token. The `ServiceProviderRequest`base class that is used in all service methods as an input parameter has been extended with an `AuthenticationToken` property. The property can be set explicitly on every call made through Commerce Connect. If the property is not set, the `AuthenticationTokenProvider` class is instantiated and called, and the return value is assigned to the property.

The `AuthenticationToken` is defined as a class that can be customized for extensibility purposes.

The following is an example of how to explicitly pass the authentication token into a service call:

```

var request = new GetCustomerRequest(customerId);
var token = this.EntityFactory.Create<AuthenticationToken>("AuthenticationToken");

token.Token = "mytoken";
request.AuthenticationToken = token;
var result = this.CustomerServiceProvider.GetCustomer(request);

```