来自 TikTok Shop 官方资料快照 ·
- 当前资料结构化阅读页
- 固定快照已留存,可追溯
- 官方原文可核对
资料正文
§1 Connecting and managing TikTok shops
A core scenario for TikTok Shop API developers is to create, manage, and disconnect a persistent connection between a local customer account in your system and that customer's TikTok Shop seller account.
Seller authorization only: This guide applies to Seller authorization, where a customer authorizes your app to access TikTok Shop Seller and shop data. Creator authorization and partner authorization use different entry points and may authorize different data owners. See Creator authorization guide and Partner authorization guide if your app needs creator-owned or partner-owned data.
§3 Manage TikTok Shop connections
Manage TikTok Shop connections
A basic requirement for this use case is indexing your local customer data to TikTok Shop data. This allows you to look up the credentials and shop identifiers needed to call TikTok Shop APIs on a customer's behalf.
You must securely store your customer's TikTok Shop access and refresh tokens and associate them with your own local customer identifier. An access_token is the credential used to access customer data, but it does not contain enough shop-identifying information by itself. Store the token response and authorized shop data together so you can retrieve the correct token and shop identifiers when making API calls.
You must also store token expiration timestamps so your system can refresh tokens before access expires and reauthorize the app when refresh access expires.
If you serve customers with cross-border shops in China, also store the
shop_cipherassociated with each TikTok Shop.shop_cipheris required by many shop-scoped endpoints for cross-border shops in China. It is optional for local shops in the US, UK, and SEA markets unless an endpoint reference explicitly requires it.
Finally, we recommend storing all TikTok Shop metadata returned by Get Authorized Shops, because it does not change frequently. Also provide a way for customers to refresh their TikTok Shop data from your application or connector, because customers are most likely to know when their shop details have changed.
Image
Text alternative for the diagram: the customer authorizes your app, TikTok Shop redirects to your callback URL with a one-time code, your backend exchanges that code for tokens, and your backend stores the token response against your local customer record. Later, your backend uses the stored access_token and x-tts-access-token header to call TikTok Shop Open APIs.
The call flow is:
- Your customer authorizes your TikTok Shop App to access their TikTok Shop Seller data. If your app is published in the TikTok Shop App Store, the customer authorizes it by clicking the Install button. Otherwise, provide a Seller authorization link so the customer can sign in with their TikTok Shop Seller account and authorize your app.
- After authorization, TikTok Shop calls your configured callback URL with URL parameters, including
code. Thiscodeis a short-lived, one-time authorization code. Do not store it as a reusable credential. - Exchange the
codefor an access token and refresh token by calling the token endpoint from your backend:
GET https://auth.tiktok-shops.com/api/v2/token/get?app_key={app_key}&app_secret={app_secret}&auth_code={code}&grant_type=authorized_code
Required query parameters:
| Parameter | Required | Description |
|---|---|---|
app_key | Yes | The App Key generated for your TikTok Shop App. |
app_secret | Yes | The App Secret generated for your TikTok Shop App. Keep it on the server side and never expose it in frontend code, logs, or screenshots. |
auth_code | Yes | The code value returned to your callback URL after Seller authorization. |
grant_type | Yes | Must be authorized_code. Do not use the standard OAuth spelling authorization_code. |
Example successful token response:
{
"code": 0,
"message": "success",
"data": {
"access_token": "TTP_example_access_token",
"access_token_expire_in": 1660556783,
"refresh_token": "TTP_example_refresh_token",
"refresh_token_expire_in": 1691487031,
"open_id": "7010736057180325637",
"seller_name": "Example Shop",
"seller_base_region": "ID",
"user_type": 0,
"granted_scopes": [
"seller.affiliate_collaboration.read",
"seller.affiliate_collaboration.write"
]
},
"request_id": "2022080809462301024509910319695C45"
}
Token field quick reference:
| Field | Meaning | Store it? |
|---|---|---|
access_token | Bearer credential used to call TikTok Shop Open APIs. For 202309 and newer APIs, pass it in the x-tts-access-token header. | Yes. Store securely and encrypt at rest. |
access_token_expire_in | Access token expiration time, expressed as Unix epoch seconds. | Yes. Use it to refresh before the access token expires. |
refresh_token | Credential used to request a new access token. | Yes. Store securely and restrict access more tightly than ordinary shop metadata. |
refresh_token_expire_in | Refresh token expiration time, expressed as Unix epoch seconds. | Yes. Use it to trigger reauthorization before or after refresh access expires. |
open_id | Identifier of the authorizing user or authorization principal. | Recommended. Useful for diagnostics and audit trails. |
seller_name | Seller name returned by the token API. | Recommended. Useful for display and support. |
seller_base_region | Seller base region. | Recommended. Useful for routing and support. |
user_type | Authorization principal type. 0 indicates a TikTok Shop Seller token. | Recommended. Validate that the token type matches the API you intend to call. |
granted_scopes | API scopes granted during authorization. | Recommended. Use it to detect missing scopes before API calls fail. |
§4 Connecting a single shop
Connecting a single shop
Use this model if each local customer account can connect to only one TikTok Shop and you do not plan to support multiple TikTok Shops for the same customer.
In your local data store, CustomerID can be unique in the shop connection table because each customer maps to only one shop connection.
Image
Text alternative for the diagram: one local customer record maps to one TikTok Shop row. The row stores the customer identifier, token metadata, and the shop data returned by Get Authorized Shops.
§5 Connecting multiple shops
Connecting multiple shops
Use this model if a customer can have more than one TikTok Shop associated with their TikTok Seller account, or if you may support this in the future.
In your local data store, CustomerID cannot be the unique key in the shop connection table because one customer may have multiple shop rows. Use a composite key such as CustomerID + shop_cipher or CustomerID + shop_id, depending on the identifiers required by your endpoints and internal data model.
Image
Text alternative for the diagram: one local customer record maps to multiple TikTok Shop rows. Each row stores the same local customer identifier and a different TikTok Shop identifier, shop cipher, and shop metadata.
§6 Single-shop and multiple-shop comparison
Single-shop and multiple-shop comparison
Both connection models use the same token exchange and Get Authorized Shops API. The key difference is how you model the local customer-to-shop relationship.
| Item | Single-shop model | Multiple-shop model |
|---|---|---|
| Customer-to-shop relationship | One local customer maps to one TikTok Shop. | One local customer can map to multiple TikTok Shops. |
CustomerID uniqueness | CustomerID can be unique in the shop connection table. | CustomerID cannot be unique by itself. |
| Suggested unique key | CustomerID | CustomerID + shop_cipher or CustomerID + shop_id |
| Get Authorized Shops response handling | Expect one shop object in data.shops. | Iterate all shop objects in data.shops. |
| Future flexibility | Simpler, but harder to expand later. | More flexible and recommended if multi-shop support is possible. |
To retrieve authorized shop data in either model:
- Retrieve the stored
access_tokenfor the local customer. - Call Get Authorized Shops:
GET https://open-api.tiktokglobalshop.com/authorization/202309/shops?app_key={app_key}×tamp={timestamp}&sign={sign}
Content-Type: application/json
x-tts-access-token: {access_token}
- Read the returned
data.shopsarray. Each object represents a TikTok Shop authorized by the Seller token. - Store the returned shop fields, especially identifiers such as
cipher,id,code,name,region, andseller_type, against your local customer record.
Example response shape:
{
"code": 0,
"data": {
"shops": [
{
"cipher": "ROW_xkMbgAAAeVAQra0eZWebFQq5aIK",
"code": "123456789",
"id": "7495355150342452340",
"name": "Example TikTok Shop",
"region": "US",
"seller_type": "LOCAL"
}
]
},
"message": "Success",
"request_id": "20230901000000000000000000000000"
}
§7 Next steps
Next steps
Once you have connected one or more TikTok Shops, implement an authorization expiration webhook listener and add functionality to disconnect a shop. Use the reauthorization flow for authorization-expiration or deauthorization events so customers can reconnect their shop when access is still required.
