> ## 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.

# 更新 User Store ID 金鑰

> 在 User Store ID 金鑰的 30 天有效期限到期之前，於 Microsoft Store 服務中更新該金鑰，讓您的後端能繼續驗證呼叫。

本文說明如何更新 User Store ID 金鑰。

當您[產生 User Store ID 金鑰](/zh-TW/publishing/xstore-commerce/xstore-requesting-userstoreid#step-4-create-a-user-store-id-key)時，其有效期限為 30 天。在這段期間內，該金鑰可以驗證對 Microsoft Store 服務的呼叫。您可以在到期之前更新金鑰，為相同的 Microsoft Entra 應用程式用戶端 ID 和使用者身分產生新的金鑰。

## 必要條件

若要更新 User Store ID 金鑰，您需要下列金鑰/權杖：

* 具有對象 URI 值 `https://onestore.microsoft.com` 的 Microsoft Entra ID 存取權杖
* [從您應用程式的用戶端程式碼產生](/zh-TW/publishing/xstore-commerce/xstore-requesting-userstoreid#step-4-create-a-user-store-id-key)的已過期 Microsoft Store ID 金鑰。

如需詳細資訊，請參閱[要求 User Store ID 以進行服務對服務驗證](/zh-TW/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` | 已重新整理的 User Store ID 金鑰，可用於日後對 Microsoft Store Collections API 或 Purchase API 的呼叫 |

### 回應範例

```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` | User Store ID 金鑰中的 `clientId` 宣告與 Microsoft Entra ID 存取權杖中的 `appid` 宣告不相符。 |

## 參考 API 文件

* [XStore (API 內容)](/zh-TW/reference/system/xstore/xstore_members)

## 另請參閱

[Commerce (概觀)](/zh-TW/publishing/xstore-commerce/xstore-commerce-overview)

[從您的服務管理產品](/zh-TW/publishing/xstore-commerce/xstore-authenticating-service)

[要求 User Store ID 以進行服務對服務驗證](/zh-TW/publishing/xstore-commerce/xstore-requesting-userstoreid)

[使用 X-token 或 OAuth 2.0 從您的服務要求 User Store ID](/zh-TW/publishing/xstore-commerce/xstore-requesting-userstoreid-oauth)

[使用 Microsoft Store API 驗證您的服務](/zh-TW/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 參考)](/zh-TW/reference/system/xstore/xstore_members)


## Related topics

- [ユーザー Store ID キーを更新する](/ja-jp/publishing/xstore-commerce/xstore-renew-userstoreid.md)
- [サービス間認証用のユーザー Store ID を要求する](/ja-jp/publishing/xstore-commerce/xstore-requesting-userstoreid.md)
- [Renewing a User Store ID key](/publishing/xstore-commerce/xstore-renew-userstoreid.md)
- [User Store ID 키 갱신](/ko/publishing/xstore-commerce/xstore-renew-userstoreid.md)
- [续订 User Store ID 密钥](/zh-CN/publishing/xstore-commerce/xstore-renew-userstoreid.md)
