Refresh tokens

Refresh tokens are credentials used to obtain new access tokens without asking the user to authorize your application again. For more information, see RFC 6749.

When you redeem an authorization code for an access token, a refresh token is issued, too. When the access token expires, use the refresh token to get a new one. After a refresh token expires or is revoked, the user needs to authorize your application again.

Each time a user authorizes your application, you get a new access token and refresh token. Tokens from earlier authorizations keep working until they expire or are revoked.

Which Endpoint to Use

Use Get Access Token v4 (POST https://api.yelp.com/oauth2/token/v4). It follows OAuth 2.1: every refresh returns a new refresh token, and errors use the OAuth 2.1 format.

🚧

TOKEN_V4_REQUIRED

If Get Access Token v2 or v3 returns 400 with the error code TOKEN_V4_REQUIRED, your application must use v4. Some existing applications can still use v2 and v3. See Get Access Token v2 and v3.

Token Lifetimes

v4v2 and v3
Access token1 hour7 days
Refresh token90 days by default365 days by default
New refresh token on every refreshYesv2: no. v3: yes

Each response tells you when its tokens expire, in expires_in / expires_on and refresh_token_expires_in / refresh_token_expires_on. Use those fields rather than hard-coding the lifetimes.

The lifetimes depend on the endpoint that issued the token:

  • Moving from v2 or v3 to v4 shortens your tokens. A refresh token you already hold keeps its expiry until you refresh it. The first refresh on v4 returns tokens with the v4 lifetimes.
  • If you have an agreement with Yelp for longer-lived refresh tokens, it doesn't carry over to v4 automatically. Contact your Yelp relationship manager before you move to v4.

Refreshing an Access Token on v4

Every refresh on v4 rotates the refresh token: the response includes a new refresh token, and the one you sent stops working.

Request

POST /oauth2/token/v4 HTTP/1.1
Host: api.yelp.com
Content-Type: application/x-www-form-urlencoded

client_id={client_id}&
client_secret={client_secret}&
grant_type=refresh_token&
refresh_token={refresh_token}

Send client_id and client_secret in the form body. v4 doesn't accept them in an Authorization header.

You can add an optional scope parameter with a space-separated subset of the token's scopes. You can't request a scope the token doesn't already have. The new refresh token only carries the scopes you requested, so later refreshes can't get the others back.

Response

{
  "access_token": "<128_character_long_string>",
  "token_type": "Bearer",
  "expires_in": 3600,
  "expires_on": "2026-11-10T20:00:00+00:00",
  "refresh_token": "<128_character_long_string>",
  "refresh_token_expires_in": 7776000,
  "refresh_token_expires_on": "2027-02-08T19:00:00+00:00"
}

A refresh response doesn't include scope. The tokens keep the scopes the user authorized, or the subset you requested.

Storing the New Refresh Token

  1. Refresh when the access token expires. Check expires_on, or refresh shortly before it.
  2. Save the new refresh token before you use the new access token. The refresh token you sent no longer works, so if you lose the new one, the user needs to authorize your application again.
  3. Store the new refresh token every time, replacing the old one.
  4. Send one refresh at a time for each user, so you always know which refresh token is the current one.

Retries and Reuse Detection

❗️

Don't reuse a refresh token more than 60 seconds after refreshing with it

Yelp treats this as a sign that the token was stolen, and revokes the newest refresh token issued from it. The user then needs to authorize your application again.

You can retry a refresh for 60 seconds. If a refresh request fails before you get the response (a timeout or a dropped connection, for example), send the same request again with the same refresh token. Within 60 seconds of the first request succeeding, Yelp returns the same new access token and refresh token instead of an error.

After 60 seconds, a reused refresh token is treated as stolen (RFC 9700 §4.14). The request fails with invalid_grant, and Yelp also revokes the newest refresh token issued from it, even if you stored it correctly.

To avoid this:

  • Retry a failed refresh straight away, not on a delayed job.
  • Don't keep old refresh tokens anywhere they could be sent again, such as a cache or a retry queue.
  • If a refresh returns invalid_grant, stop retrying. Discard the user's tokens and send them through the Authorization Code Workflow again.

Error Scenarios

v4 errors use the OAuth 2.1 format: a string error code and an error_description. This is different from the {"error": {"code": …, "description": …}} format used by v2, v3 and other Yelp APIs.

{
  "error": "invalid_grant",
  "error_description": "Invalid token"
}
HTTP CodeError CodeDescription
400 - Bad Requestinvalid_grantThe refresh token is unknown, expired or revoked, or it was reused more than 60 seconds after a refresh.
400 - Bad Requestinvalid_requestA required parameter, such as refresh_token, is missing or invalid.
400 - Bad Requestinvalid_scopescope includes a scope the refresh token doesn't have, or your application is no longer allowed one of the token's scopes.
400 - Bad Requestinvalid_clientThe client_id or client_secret is missing or wrong.
401 - Unauthorizedinvalid_clientThe client_id or client_secret is missing or wrong, and the request included an Authorization header. The response includes a WWW-Authenticate header.
429 - Too Many Requeststoo_many_requestsYou have exceeded the rate limit. Try again later.
500 - Internal Server Errorserver_errorServer error. Retry straight away with the same refresh token (see Retries and Reuse Detection).

For the full schema, see Get Access Token v4.

Get Access Token v2 and v3

📘

Use v4 for new integrations

Some existing applications can still use v2 and v3, and they keep working as described here. We recommend moving to v4. If either endpoint returns TOKEN_V4_REQUIRED, your application must use v4.

Both endpoints take the same request as v4, with client_id, client_secret, grant_type=refresh_token and refresh_token in the form body.

v2 and v3 use the 7 day and 365 day lifetimes (see Token Lifetimes) and the Yelp error format.

v2 Response

{
  "access_token": "<128_character_long_string>",
  "token_type": "Bearer",
  "expires_in": 604800,
  "expires_on": "2026-11-17T19:00:00+00:00"
}

v3 Response

{
  "access_token": "<128_character_long_string>",
  "token_type": "Bearer",
  "expires_in": 604800,
  "expires_on": "2026-11-17T19:00:00+00:00",
  "refresh_token": "<128_character_long_string>",
  "refresh_token_expires_in": 31536000,
  "refresh_token_expires_on": "2027-11-10T19:00:00+00:00"
}

Did this page help you?