API tokens, scopes and rotation
In short
Give each marketplace integration only the scopes it needs, keep access tokens short-lived and protect refresh tokens as carefully as a password.
A marketplace integration holds the keys to real orders and listings. The safest setup gives each integration only the access it needs, keeps access tokens short-lived, and protects refresh tokens as carefully as a password. This article explains the OAuth 2.0 terms you will meet, and gives a practical routine for scopes, expiry and rotation.
Access tokens and refresh tokens
RFC 6749, which defines OAuth 2.0, separates two tokens. The access token is sent with each API call. The refresh token is used only to obtain a new access token. The standard says that refresh tokens are intended for use only with the authorisation server, not with the resource the API serves. The server decides whether to issue a refresh token at all.
The response that carries an access token may include the expires_in parameter, which gives the lifetime in seconds. The standard marks this parameter as recommended, so an integration should not assume that a token lasts for ever.
Scopes and least privilege
A scope limits what a token may do. RFC 6749 says that the authorisation server may fully or partially ignore the scope the client requests. Access tokens may also carry fewer permissions than the grant that produced them. In practice, ask only for the scopes that a job uses. An integration that reads orders does not need to change prices, and a token for a report should not be able to publish listings. For the people who log in to your account, see Giving staff access to a seller account.
For flippers and resellers: Manual work around every sale costs you time and margin. MarketShield is building tools to cut it down – within platform rules. Closed access for now. Get early access
Expiry and rotation
RFC 6750, which covers bearer tokens, recommends short-lived tokens of one hour or less, and says that an expired or revoked token is refused. When an access token is refused, the client may request a new one. Some servers rotate refresh tokens and issue a new one with each refresh. When a new refresh token is issued, RFC 6749 requires the client to discard the old one and replace it. RFC 9700, the OAuth 2.0 Security Best Current Practice, adds in Section 4.14 that if a rotated token is then used twice, one of the two copies stops working, which can expose that the token was taken.
Storage and transport
- Send tokens only over TLS. RFC 6750 says that clients must always use TLS, or equivalent transport security, when they make requests with bearer tokens.
- Keep refresh tokens confidential. RFC 6749 says that refresh tokens must be kept confidential in transit and in storage.
- Keep tokens away from unintended parties. RFC 6750 requires clients to ensure that bearer tokens are not leaked to unintended parties. Keep tokens out of logs, screenshots, shared spreadsheets and browser code.
- Keep secrets out of source code. Store them in a secrets manager, or in the environment of the server that runs the job. Login protection for your own account is covered in securing a seller account.
A rotation routine
- List every integration, the person who owns it, and the scopes it uses.
- Remove any scope that the integration no longer needs, and test the job afterwards.
- Set a review date for each token, and record it in your register.
- When a person leaves, or a tool is retired, revoke its tokens at once in the marketplace developer account.
- After each rotation, check that the old token is refused and that the new one works, then record the change.
Each marketplace documents its own token types, scopes and lifetimes. Use its documentation for the actual values, and use this routine for the habits. If the marketplace rejects a token or limits a call, see Handling API rate limits safely.
This article explains the OAuth 2.0 standard and general security habits. It is not legal advice, and it does not replace the developer documentation of your marketplace, which sets the actual scopes and lifetimes.
Common questions
- What is the difference between an access token and a refresh token?
- The access token is sent with API calls and is short-lived. The refresh token is used only to obtain a new access token from the authorisation server, and it must be kept confidential.
- Can a refresh token be shared between two servers?
- No. RFC 6749 says that refresh tokens should be shared only between the authorisation server and the client they were issued to, and that the server must keep that binding.
- What should I do if a token may have leaked?
- Revoke it in the marketplace developer account, issue a new one, and review logs for the period when it may have been exposed. Record each step.
Sources
- RFC 6749: The OAuth 2.0 Authorization Framework IETF · 24 Nov 2026
- RFC 9700: Best Current Practice for OAuth 2.0 Security IETF · 24 Nov 2026
- RFC 6750: The OAuth 2.0 Authorization Framework: Bearer Token Usage IETF · 24 Nov 2026
Further reading
- Giving staff access to a seller account Each team member should have a separate login with only the permissions their role needs, and access should be checked and removed on the day someone leaves. 4 min read
- Securing a marketplace seller account Turn on two-step verification, recognise phishing messages, and if an account is compromised, change the passwords and contact the platform straight away. 4 min read
- Handling API rate limits safely When a marketplace API returns HTTP 429, wait before retrying, add jitter to each wait and stop after a set number of attempts. 4 min read
MarketShield is in closed access. You can request early access.
Get early access