{"abstract":[{"text":"Validate an authorization grant code delivered to your app to obtain tokens, or validate an existing refresh token.","type":"text"}],"hierarchy":{"paths":[["doc:\/\/com.apple.documentation\/documentation\/technologies","doc:\/\/com.apple.signinwithapple\/documentation\/SigninwithAppleRESTAPI"]]},"identifier":{"interfaceLanguage":"data","url":"doc:\/\/com.apple.signinwithapple\/documentation\/SigninwithAppleRESTAPI\/Generate-and-validate-tokens"},"kind":"symbol","legalNotices":{"copyright":"Copyright &copy; 2026 Apple Inc. All rights reserved.","privacyPolicy":"https:\/\/www.apple.com\/privacy\/privacy-policy","termsOfUse":"https:\/\/www.apple.com\/legal\/internet-services\/terms\/site.html"},"metadata":{"availableLanguages":["de-DE","en-US","es-419","fr-FR","it-IT","ja-JP","ko-KR","pt-BR","zh-CN"],"externalID":"rest:appleid_signin_server_api:post:auth-token","modules":[{"name":"Sign in with Apple REST API"}],"navigatorTitle":[{"kind":"text","text":"Token validation"}],"platforms":[{"introducedAt":"1.0","name":"Sign in with Apple REST API"}],"role":"symbol","roleHeading":"Web Service Endpoint","symbolKind":"httpRequest","title":"Token validation"},"primaryContentSections":[{"kind":"restEndpoint","title":"URL","tokens":[{"kind":"method","text":"POST"},{"kind":"text","text":" "},{"kind":"baseURL","text":"https:\/\/appleid.apple.com\/"},{"kind":"path","text":"auth\/token"}]},{"bodyContentType":[{"kind":"text","text":"form-data"}],"content":[{"inlineContent":[{"text":"The list of input parameters required for the server to validate the authorization code or refresh token.","type":"text"}],"type":"paragraph"}],"kind":"restBody","mimeType":"application\/x-www-form-urlencoded","parameters":[{"attributes":[],"content":[{"inlineContent":[{"text":"The identifier (App ID or Services ID) for your app. The identifier must not include your Team ID, to help prevent the possibility of exposing sensitive data to the end user.","type":"text"}],"type":"paragraph"}],"name":"client_id","required":true,"type":[{"kind":"text","text":"string"}]},{"attributes":[],"content":[{"inlineContent":[{"text":"A secret JSON Web Token, generated by the developer, that uses the Sign in with Apple ","type":"text"},{"identifier":"https:\/\/developer.apple.com\/help\/account\/capabilities\/create-a-sign-in-with-apple-private-key","isActive":true,"type":"reference"},{"text":" associated with your developer account. Authorization code and refresh token validation requests require this parameter. To create this token, see  ","type":"text"},{"identifier":"doc:\/\/com.apple.documentation\/documentation\/AccountOrganizationalDataSharing\/creating-a-client-secret","isActive":true,"type":"reference"},{"text":".","type":"text"}],"type":"paragraph"}],"name":"client_secret","required":true,"type":[{"kind":"text","text":"string"}]},{"attributes":[],"content":[{"inlineContent":[{"text":"The authorization code received in an authorization response sent to your app. The code is single-use only and valid for five minutes. Authorization code validation requests require this parameter.","type":"text"}],"type":"paragraph"}],"name":"code","required":false,"type":[{"kind":"text","text":"string"}]},{"attributes":[],"content":[{"inlineContent":[{"text":"The grant type determines how the client app interacts with the validation server. Authorization code and refresh token validation requests require this parameter. For authorization code validation, use ","type":"text"},{"code":"authorization_code","type":"codeVoice"},{"text":". For refresh token validation requests, use ","type":"text"},{"code":"refresh_token","type":"codeVoice"},{"text":".","type":"text"}],"type":"paragraph"}],"name":"grant_type","required":true,"type":[{"kind":"text","text":"string"}]},{"attributes":[],"content":[{"inlineContent":[{"text":"The refresh token received from the validation server during an authorization request. Refresh token validation requests require this parameter.","type":"text"}],"type":"paragraph"}],"name":"refresh_token","required":false,"type":[{"kind":"text","text":"string"}]},{"attributes":[],"content":[{"inlineContent":[{"text":"The destination URI provided in the authorization request when authorizing a user with your app, if applicable. The URI must use the HTTPS protocol, include a domain name, and can’t contain an IP address or ","type":"text"},{"code":"localhost","type":"codeVoice"},{"text":", and must not contain a fragment identifer (#). Authorization code requests require this parameter. For more information, see ","type":"text"},{"identifier":"doc:\/\/com.apple.signinwithapple\/documentation\/signinwithapple\/configuring-your-environment-for-sign-in-with-apple","isActive":true,"type":"reference"}],"type":"paragraph"}],"name":"redirect_uri","required":false,"type":[{"kind":"text","text":"string"}]}],"title":"HTTP Body"},{"items":[{"content":[{"inlineContent":[{"text":"The request was successful.","type":"text"}],"type":"paragraph"}],"mimeType":"application\/json","reason":"OK","status":200,"type":[{"identifier":"doc:\/\/com.apple.signinwithapple\/documentation\/SigninwithAppleRESTAPI\/TokenResponse","kind":"typeIdentifier","preciseIdentifier":"data:appleid_signin_server_api:TokenResponse","text":"TokenResponse"}]},{"content":[{"inlineContent":[{"text":"The server was unable to process the request.","type":"text"}],"type":"paragraph"}],"mimeType":"application\/json","reason":"Bad Request","status":400,"type":[{"identifier":"doc:\/\/com.apple.signinwithapple\/documentation\/SigninwithAppleRESTAPI\/ErrorResponse","kind":"typeIdentifier","preciseIdentifier":"data:appleid_signin_server_api:ErrorResponse","text":"ErrorResponse"}]}],"kind":"restResponses","title":"Response Codes"},{"kind":"mentions","mentions":["doc:\/\/com.apple.signinwithapple\/documentation\/signinwithapple\/verifying-a-user","doc:\/\/com.apple.signinwithapple\/documentation\/signinwithapple\/configuring-your-webpage-for-sign-in-with-apple","doc:\/\/com.apple.signinwithapple\/documentation\/signinwithapple\/receiving-a-users-identity-token"]},{"content":[{"anchor":"Discussion","level":2,"text":"Discussion","type":"heading"},{"inlineContent":[{"text":"The validation server returns a ","type":"text"},{"identifier":"doc:\/\/com.apple.signinwithapple\/documentation\/SigninwithAppleRESTAPI\/TokenResponse","isActive":true,"type":"reference"},{"text":" 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.","type":"text"}],"type":"paragraph"},{"anchor":"Validate-the-authorization-grant-code","level":3,"text":"Validate the authorization grant code","type":"heading"},{"inlineContent":[{"text":"When you send an authorization request to the validation server, include the following form data parameters:","type":"text"}],"type":"paragraph"},{"items":[{"content":[{"inlineContent":[{"code":"client_id","type":"codeVoice"}],"type":"paragraph"}]},{"content":[{"inlineContent":[{"code":"client_secret","type":"codeVoice"}],"type":"paragraph"}]},{"content":[{"inlineContent":[{"code":"code","type":"codeVoice"}],"type":"paragraph"}]},{"content":[{"inlineContent":[{"code":"grant_type","type":"codeVoice"}],"type":"paragraph"}]},{"content":[{"inlineContent":[{"code":"redirect_uri","type":"codeVoice"}],"type":"paragraph"}]}],"type":"unorderedList"},{"content":[{"inlineContent":[{"text":"","type":"text"},{"text":" ","type":"text"},{"text":"When authorizing a user with your app, include the ","type":"text"},{"code":"redirect_uri","type":"codeVoice"},{"text":" parameter only if the application provided a ","type":"text"},{"code":"redirect_uri","type":"codeVoice"},{"text":" in the initial authorization request.","type":"text"}],"type":"paragraph"}],"name":"Note","style":"note","type":"aside"},{"inlineContent":[{"text":"The following is an example authorization validation request URL via ","type":"text"},{"code":"cURL","type":"codeVoice"},{"text":":","type":"text"}],"type":"paragraph"},{"code":["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'"],"copyToClipboard":true,"lineAnnotations":[],"showLineNumbers":false,"syntax":"console","type":"codeListing","wrap":0},{"inlineContent":[{"text":"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:","type":"text"}],"type":"paragraph"},{"code":["{","  \"access_token\": \"adg61...67Or9\",","  \"token_type\": \"Bearer\",","  \"expires_in\": 3600,","  \"refresh_token\": \"rca7...lABoQ\",","  \"id_token\": \"eyJra...96sZg\"","}"],"copyToClipboard":true,"lineAnnotations":[],"showLineNumbers":false,"syntax":"json","type":"codeListing","wrap":0},{"inlineContent":[{"text":"Use the refresh token to verify the user session from the server and obtain access tokens.","type":"text"}],"type":"paragraph"},{"anchor":"Validate-an-existing-refresh-token","level":3,"text":"Validate an existing refresh token","type":"heading"},{"inlineContent":[{"text":"When performing a validation request, you must include the following form data parameters:","type":"text"}],"type":"paragraph"},{"items":[{"content":[{"inlineContent":[{"code":"client_id","type":"codeVoice"}],"type":"paragraph"}]},{"content":[{"inlineContent":[{"code":"client_secret","type":"codeVoice"}],"type":"paragraph"}]},{"content":[{"inlineContent":[{"code":"grant_type","type":"codeVoice"}],"type":"paragraph"}]},{"content":[{"inlineContent":[{"code":"refresh_token","type":"codeVoice"}],"type":"paragraph"}]}],"type":"unorderedList"},{"inlineContent":[{"text":"The following is an example validation request URL using ","type":"text"},{"code":"cURL","type":"codeVoice"},{"text":":","type":"text"}],"type":"paragraph"},{"code":["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'"],"copyToClipboard":true,"lineAnnotations":[],"showLineNumbers":false,"syntax":"console","type":"codeListing","wrap":0},{"inlineContent":[{"text":"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:","type":"text"}],"type":"paragraph"},{"code":["{","  \"access_token\": \"beg510...67Or9\",","  \"token_type\": \"Bearer\",","  \"expires_in\": 3600,","  \"id_token\": \"eyJra...96sZg\"","}"],"copyToClipboard":true,"lineAnnotations":[],"showLineNumbers":false,"syntax":"json","type":"codeListing","wrap":0}],"kind":"content"}],"schemaVersion":{"major":0,"minor":3,"patch":0},"sections":[],"seeAlsoSections":[{"anchor":"Generating-and-revoking-tokens","generated":true,"identifiers":["doc:\/\/com.apple.documentation\/documentation\/AccountOrganizationalDataSharing\/creating-a-client-secret","doc:\/\/com.apple.signinwithapple\/documentation\/SigninwithAppleRESTAPI\/Fetch-Apple's-public-key-for-verifying-token-signature","doc:\/\/com.apple.signinwithapple\/documentation\/SigninwithAppleRESTAPI\/Revoke-tokens"],"title":"Generating and revoking tokens"}],"variants":[{"paths":["\/documentation\/signinwithapplerestapi\/generate-and-validate-tokens"],"traits":[{"interfaceLanguage":"data"}]}],"references":{"doc://com.apple.documentation/documentation/AccountOrganizationalDataSharing/creating-a-client-secret":{"abstract":[{"text":"Generate a signed token to identify your client application.","type":"text"}],"identifier":"doc:\/\/com.apple.documentation\/documentation\/AccountOrganizationalDataSharing\/creating-a-client-secret","kind":"article","role":"article","title":"Creating a client secret","type":"topic","url":"\/documentation\/accountorganizationaldatasharing\/creating-a-client-secret"},"doc://com.apple.documentation/documentation/technologies":{"abstract":[],"identifier":"doc:\/\/com.apple.documentation\/documentation\/technologies","kind":"technologies","role":"overview","title":"Technologies","type":"topic","url":"\/documentation\/technologies"},"doc://com.apple.signinwithapple/documentation/SigninwithAppleRESTAPI":{"abstract":[{"text":"Communicate between your app servers and Apple’s authentication servers.","type":"text"}],"identifier":"doc:\/\/com.apple.signinwithapple\/documentation\/SigninwithAppleRESTAPI","kind":"symbol","navigatorTitle":[{"kind":"text","text":"Sign in with Apple REST API"}],"role":"collection","title":"Sign in with Apple REST API","type":"topic","url":"\/documentation\/signinwithapplerestapi"},"doc://com.apple.signinwithapple/documentation/SigninwithAppleRESTAPI/ErrorResponse":{"abstract":[{"text":"The error object returned after an unsuccessful request.","type":"text"}],"fragments":[{"kind":"text","text":"object "},{"kind":"identifier","text":"ErrorResponse"}],"identifier":"doc:\/\/com.apple.signinwithapple\/documentation\/SigninwithAppleRESTAPI\/ErrorResponse","kind":"symbol","navigatorTitle":[{"kind":"identifier","text":"ErrorResponse"}],"role":"symbol","title":"ErrorResponse","type":"topic","url":"\/documentation\/signinwithapplerestapi\/errorresponse"},"doc://com.apple.signinwithapple/documentation/SigninwithAppleRESTAPI/Fetch-Apple's-public-key-for-verifying-token-signature":{"abstract":[{"text":"Fetch Apple’s public key to verify ID token and server notification signatures.","type":"text"}],"identifier":"doc:\/\/com.apple.signinwithapple\/documentation\/SigninwithAppleRESTAPI\/Fetch-Apple's-public-key-for-verifying-token-signature","kind":"symbol","navigatorTitle":[{"kind":"text","text":"Fetch Apple’s public key to verify token signatures"}],"role":"symbol","title":"Fetch Apple’s public key to verify token signatures","type":"topic","url":"\/documentation\/signinwithapplerestapi\/fetch-apple's-public-key-for-verifying-token-signature"},"doc://com.apple.signinwithapple/documentation/SigninwithAppleRESTAPI/Generate-and-validate-tokens":{"abstract":[{"text":"Validate an authorization grant code delivered to your app to obtain tokens, or validate an existing refresh token.","type":"text"}],"identifier":"doc:\/\/com.apple.signinwithapple\/documentation\/SigninwithAppleRESTAPI\/Generate-and-validate-tokens","kind":"symbol","navigatorTitle":[{"kind":"text","text":"Token validation"}],"role":"symbol","title":"Token validation","type":"topic","url":"\/documentation\/signinwithapplerestapi\/generate-and-validate-tokens"},"doc://com.apple.signinwithapple/documentation/SigninwithAppleRESTAPI/Revoke-tokens":{"abstract":[{"text":"Invalidate the tokens and associated user authorizations for a user when they are no longer associated with your app.","type":"text"}],"identifier":"doc:\/\/com.apple.signinwithapple\/documentation\/SigninwithAppleRESTAPI\/Revoke-tokens","kind":"symbol","navigatorTitle":[{"kind":"text","text":"Token revocation"}],"role":"symbol","title":"Token revocation","type":"topic","url":"\/documentation\/signinwithapplerestapi\/revoke-tokens"},"doc://com.apple.signinwithapple/documentation/SigninwithAppleRESTAPI/TokenResponse":{"abstract":[{"text":"The response token object returned on a successful request.","type":"text"}],"fragments":[{"kind":"text","text":"object "},{"kind":"identifier","text":"TokenResponse"}],"identifier":"doc:\/\/com.apple.signinwithapple\/documentation\/SigninwithAppleRESTAPI\/TokenResponse","kind":"symbol","navigatorTitle":[{"kind":"identifier","text":"TokenResponse"}],"role":"symbol","title":"TokenResponse","type":"topic","url":"\/documentation\/signinwithapplerestapi\/tokenresponse"},"doc://com.apple.signinwithapple/documentation/signinwithapple/configuring-your-environment-for-sign-in-with-apple":{"abstract":[{"text":"Authenticate users with your web service by associating an existing app with a Services ID and private key.","type":"text"}],"identifier":"doc:\/\/com.apple.signinwithapple\/documentation\/signinwithapple\/configuring-your-environment-for-sign-in-with-apple","kind":"article","role":"article","title":"Configuring your environment for Sign in with Apple","type":"topic","url":"\/documentation\/signinwithapple\/configuring-your-environment-for-sign-in-with-apple"},"doc://com.apple.signinwithapple/documentation/signinwithapple/configuring-your-webpage-for-sign-in-with-apple":{"abstract":[{"text":"Prepare your webpage to authorize users through Sign in with Apple.","type":"text"}],"identifier":"doc:\/\/com.apple.signinwithapple\/documentation\/signinwithapple\/configuring-your-webpage-for-sign-in-with-apple","kind":"article","role":"article","title":"Configuring your webpage for Sign in with Apple","type":"topic","url":"\/documentation\/signinwithapple\/configuring-your-webpage-for-sign-in-with-apple"},"doc://com.apple.signinwithapple/documentation/signinwithapple/receiving-a-users-identity-token":{"abstract":[{"text":"Retrieve the user’s information from Apple Account servers","type":"text"}],"identifier":"doc:\/\/com.apple.signinwithapple\/documentation\/signinwithapple\/receiving-a-users-identity-token","kind":"article","role":"article","title":"Receiving a User’s Identity Token","type":"topic","url":"\/documentation\/signinwithapple\/receiving-a-users-identity-token"},"doc://com.apple.signinwithapple/documentation/signinwithapple/verifying-a-user":{"abstract":[{"text":"Check the validity and integrity of a user’s identity token.","type":"text"}],"identifier":"doc:\/\/com.apple.signinwithapple\/documentation\/signinwithapple\/verifying-a-user","kind":"article","role":"article","title":"Verifying a user","type":"topic","url":"\/documentation\/signinwithapple\/verifying-a-user"},"https://developer.apple.com/help/account/capabilities/create-a-sign-in-with-apple-private-key":{"identifier":"https:\/\/developer.apple.com\/help\/account\/capabilities\/create-a-sign-in-with-apple-private-key","title":"private key","titleInlineContent":[{"text":"private key","type":"text"}],"type":"link","url":"https:\/\/developer.apple.com\/help\/account\/capabilities\/create-a-sign-in-with-apple-private-key"}}}