> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ユーザー Store ID キーを更新する

> Microsoft Store サービス内で 30 日間の有効期間が満了する前にユーザー Store ID キーを更新して、バックエンドが引き続き呼び出しを認証できるようにします。

この記事では、ユーザー Store ID キーを更新する方法について説明します。

[ユーザー Store ID キーを生成する](/publishing/xstore-commerce/xstore-requesting-userstoreid#step-4-create-a-user-store-id-key)と、有効期間は 30 日間です。その期間内、キーは Microsoft Store サービスへの呼び出しを認証できます。有効期限前にキーを更新して、同じ Microsoft Entra アプリのクライアント ID とユーザー ID に対して新しいキーを生成できます。

## 前提条件

ユーザー Store ID キーを更新するには、次のキー/トークンが必要です。

* オーディエンス URI 値が `https://onestore.microsoft.com` の Microsoft Entra ID アクセス トークン
* [アプリのクライアント側コードから生成された](/publishing/xstore-commerce/xstore-requesting-userstoreid#step-4-create-a-user-store-id-key)期限切れの Microsoft Store ID キー

詳細については、[サービス間認証用のユーザー Store ID を要求する](/publishing/xstore-commerce/xstore-requesting-userstoreid)を参照してください。

## リクエスト

### リクエスト構文

| キー タイプ        | メソッド   | リクエスト URI                                                  |
| ------------- | ------ | ---------------------------------------------------------- |
| `Collections` | `POST` | `https://collections.mp.microsoft.com/v6.0/b2b/keys/renew` |
| `Purchase`    | `POST` | `https://purchase.mp.microsoft.com/v6.0/b2b/keys/renew`    |

### リクエスト ヘッダー

| ヘッダー             | 型        | 説明                                                                             |
| ---------------- | -------- | ------------------------------------------------------------------------------ |
| `Host`           | `string` | 値 `collections.mp.microsoft.com` または `purchase.mp.microsoft.com` を設定する必要があります。 |
| `Content-Length` | `number` | リクエスト本文の長さ。                                                                    |
| `Content-Type`   | `string` | リクエストとレスポンスの型を指定します。現在サポートされている値は `application/json` のみです。                     |

### リクエスト本文

| パラメーター          | 型        | 説明                                 | 必須 |
| --------------- | -------- | ---------------------------------- | -- |
| `serviceTicket` | `string` | Microsoft Entra ID サービスのアクセス トークン。 | はい |
| `key`           | `string` | 期限切れの Microsoft Store ID キー。       | はい |

### リクエストの例

```syntax theme={null}
POST https://collections.mp.microsoft.com/v6.0/b2b/keys/renew HTTP/1.1
Content-Length: 2774
Content-Type: application/json
Host: collections.mp.microsoft.com

{
    "serviceTicket": "eyJ0eXAiOiJKV1QiLCJhb...",
    "Key": "eyJ0eXAiOiJKV1QiLCJhbG..."
}
```

## レスポンス

### レスポンス本文

| パラメーター | 型        | 説明                                                                                       |
| ------ | -------- | ---------------------------------------------------------------------------------------- |
| `key`  | `string` | Microsoft Store の collections API または purchase API への今後の呼び出しで使用できる更新済みのユーザー Store ID キー。 |

### レスポンスの例

```syntax theme={null}
HTTP/1.1 200 OK
Content-Length: 1646
Content-Type: application/json
MS-CorrelationId: bfebe80c-ff89-4c4b-8897-67b45b916e47
MS-RequestId: 1b5fa630-d672-4971-b2c0-3713f4ea6c85
MS-CV: xu2HW6SrSkyHyFh.0.0
MS-ServerId: 030011428
Date: Tue, 13 Sep 2019 07:31:12 GMT

{
    "key":"eyJ0eXAi..."
}
```

## エラー コード

| コード | エラー          | 内部エラー コード                    | 説明                                                                                                      |
| --- | ------------ | ---------------------------- | ------------------------------------------------------------------------------------------------------- |
| 401 | Unauthorized | `AuthenticationTokenInvalid` | Microsoft Entra ID アクセス トークンが無効です。場合によっては、`ServiceError` にトークンの有効期限切れや `appid` クレームの欠落など、より詳細な情報が含まれます。 |
| 401 | Unauthorized | `InconsistentClientId`       | ユーザー Store ID キーの `clientId` クレームと Microsoft Entra ID アクセス トークンの `appid` クレームが一致しません。                   |

## リファレンス API ドキュメント

* [XStore (API の内容)](/reference/system/xstore/xstore_members)

## 関連項目

[コマース (概要)](/publishing/xstore-commerce/xstore-commerce-overview)

[サービスから製品を管理する](/publishing/xstore-commerce/xstore-authenticating-service)

[サービス間認証用のユーザー Store ID を要求する](/publishing/xstore-commerce/xstore-requesting-userstoreid)

[X-Token または OAuth 2.0 を使用したサービスからのユーザー Store ID の要求](/publishing/xstore-commerce/xstore-requesting-userstoreid-oauth)

[Microsoft Store API を使用したサービスの認証](/publishing/xstore-commerce/xstore-authenticating-service)

[Microsoft.StoreServices ライブラリ (GitHub)](https://github.com/microsoft/Microsoft-Store-Services)

[Microsoft.StoreServices サンプル (GitHub)](https://github.com/microsoft/Microsoft-Store-Services-Sample)

[XStore (API リファレンス)](/reference/system/xstore/xstore_members)


## Related topics

- [サービス間認証用のユーザー Store ID を要求する](/ja-jp/publishing/xstore-commerce/xstore-requesting-userstoreid.md)
- [Microsoft Store API を使用してサービスを認証する](/ja-jp/publishing/xstore-commerce/xstore-authenticating-service.md)
- [X-Token または OAuth 2.0 を使用したユーザー Store ID の要求](/ja-jp/publishing/xstore-commerce/xstore-requesting-userstoreid-oauth.md)
- [ソーシャル マネージャーの概要](/ja-jp/services/xbox-services/community/social-manager/live-social-manager-overview.md)
- [XStoreShowPurchaseUIResult](/ja-jp/reference/system/xstore/functions/xstoreshowpurchaseuiresult.md)
