<!--
{
  "availability" : [
    "Sign in with Apple REST API: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "signinwithapple",
  "identifier" : "/documentation/SigninwithAppleRESTAPI/Generate-and-validate-tokens",
  "metadataVersion" : "0.1.0",
  "role" : "Web Service Endpoint",
  "symbol" : {
    "kind" : "Web Service Endpoint",
    "modules" : [
      "Sign in with Apple REST API"
    ],
    "preciseIdentifier" : "rest:appleid_signin_server_api:post:auth-token"
  },
  "title" : "Token validation"
}
-->

# Token validation

Validate an authorization grant code delivered to your app to obtain tokens, or validate an existing refresh token.

## Discussion

The validation server returns a [`TokenResponse`](/documentation/SigninwithAppleRESTAPI/TokenResponse) object in the response body of a successful validation request. Use this endpoint to either authorize a user by validating the authorization code received by your app, or by validating an existing refresh token to verify a user session or obtain access tokens.

### Validate the authorization grant code

When you send an authorization request to the validation server, include the following form data parameters:

- `client_id`
- `client_secret`
- `code`
- `grant_type`
- `redirect_uri`

> Note:
> When authorizing a user with your app, include the `redirect_uri` parameter only if the application provided a `redirect_uri` in the initial authorization request.

The following is an example authorization validation request URL via `cURL`:

```console
curl -v POST "https://appleid.apple.com/auth/token" \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'client_id=CLIENT_ID' \
-d 'client_secret=CLIENT_SECRET' \
-d 'code=CODE' \
-d 'grant_type=authorization_code' \
-d 'redirect_uri=REDIRECT_URI'
```

After the server validates the authorization code, the endpoint returns the identity token, an access token, and a refresh token. The following is an example authorization validation response:

```json
{
  "access_token": "adg61...67Or9",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "rca7...lABoQ",
  "id_token": "eyJra...96sZg"
}
```

Use the refresh token to verify the user session from the server and obtain access tokens.

### Validate an existing refresh token

When performing a validation request, you must include the following form data parameters:

- `client_id`
- `client_secret`
- `grant_type`
- `refresh_token`

The following is an example validation request URL using `cURL`:

```console
curl -v POST "https://appleid.apple.com/auth/token" \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'client_id=CLIENT_ID' \
-d 'client_secret=CLIENT_SECRET' \
-d 'grant_type=refresh_token' \
-d 'refresh_token=REFRESH_TOKEN'
```

After the server validates the refresh token, the endpoint returns the identity token and an access token. The following is an example refresh token validation response:

```json
{
  "access_token": "beg510...67Or9",
  "token_type": "Bearer",
  "expires_in": 3600,
  "id_token": "eyJra...96sZg"
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)