---
title: "AuthenticationTokenProviderクラス"
slug: "authenticationtokenprovider-class"
abstract: "Commerce Connect APIにおける認証およびトークンをサポートするために使用されるAuthenticationTokenProviderクラスの概要。"
---
# AuthenticationTokenProviderクラス

すべてのCommerce Connect APIでトークンを用いて認証をサポートするために、AuthenticationTokenProviderクラスを導入しました。これはSitecore.Commerce.Configファイルで定義されたインターフェースと、常に返すNULLを返すデフォルトの実装で構成されており、トークンは提供されません。

Sitecore.Commerce.configファイルは以下の認証プロバイダーおよびAuthenticationTokenエンティティ構成を定義しています:

<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/ja/developers/100/sitecore-experience-commerce/images/03000006.png)

名称

概要

**GetToken(ゲットトークン)**

必要な場合はトークンを返さなければなりません。

プロバイダーの導入により、トークン提供のロジックが集中化されます。すべてのサービスメソッドで入力パラメータとして使われるServiceProviderRequest基底クラスにAuthenticationTokenプロパティが拡張されています。このプロパティはCommerce Connectを通じてのすべての呼び出しに明示的に設定できます。プロパティが設定されていない場合、AuthenticationTokenProviderクラスがインスタンス化されて呼び出され、返却値がプロパティに割り当てられます。

AuthenticationTokenは拡張性のためにカスタマイズ可能なクラスとして定義されます。

以下は、認証トークンをサービスコールに明示的に渡す方法の例です。

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

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