Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
appleSignin
✓ const appleSignin = require('apple-signin')
✗ import appleSignin from 'apple-signin'
Package is CommonJS-only; no ESM or default export. Use require().
getAuthorizationUrl
✓ const { getAuthorizationUrl } = require('apple-signin')
✗ const { getAuthUrl } = require('apple-signin')
Function name is exactly 'getAuthorizationUrl'. No destructuring alternative if you need multiple functions.
getClientSecret
✓ const appleSignin = require('apple-signin'); const secret = appleSignin.getClientSecret({clientID, teamId, privateKeyPath, keyIdentifier})
✗ const { getClientSecret } = require('apple-signin'); getClientSecret({...})
getClientSecret expects an object with specific keys; wrong casing or missing fields causes errors.
getAuthorizationToken
✓ const appleSignin = require('apple-signin'); appleSignin.getAuthorizationToken(code, options).then(...)
✗ appleSignin.getAuthorizationToken(code, clientSecret) without options object
Second argument must be an options object containing clientID, redirectUri, and clientSecret.
verifyIdToken
✓ const appleSignin = require('apple-signin'); appleSignin.verifyIdToken(idToken, clientID).then(result => ...)
✗ appleSignin.verifyIdToken(idToken) without clientID
clientID is required as second argument to verify against expected audience.
Full authentication flow: generate auth URL, exchange code for tokens, verify ID token, and get user's unique Apple ID.
const appleSignin = require('apple-signin');
// Step 1: Generate authorization URL
const authUrl = appleSignin.getAuthorizationUrl({
clientID: process.env.APPLE_CLIENT_ID ?? '',
redirectUri: 'https://example.com/callback',
state: 'random-state-string',
scope: 'email'
});
console.log('Redirect user to:', authUrl);
// Step 2: Exchange authorization code for tokens
const clientSecret = appleSignin.getClientSecret({
clientID: process.env.APPLE_CLIENT_ID ?? '',
teamId: process.env.APPLE_TEAM_ID ?? '',
privateKeyPath: '/path/to/AuthKey.p8',
keyIdentifier: process.env.APPLE_KEY_ID ?? ''
});
const code = 'authorization-code-from-callback'; // obtain from query param
appleSignin.getAuthorizationToken(code, {
clientID: process.env.APPLE_CLIENT_ID ?? '',
redirectUri: 'https://example.com/callback',
clientSecret
}).then(tokenResponse => {
console.log('Token response:', tokenResponse);
// Step 3: Verify ID token
return appleSignin.verifyIdToken(tokenResponse.id_token, process.env.APPLE_CLIENT_ID ?? '');
}).then(decoded => {
console.log('User unique identifier:', decoded.sub);
}).catch(err => {
console.error('Authentication failed:', err);
});
Errors
Common errors & fixes
Error: Invalid client secret
The client secret JWT is malformed or has mismatched claims (e.g., wrong teamId or clientID).
fixCheck that teamId, clientID, keyIdentifier, and privateKeyPath are correct. Regenerate private key if needed.
Error: invalid_request: The 'redirect_uri' parameter does not match any registered redirect URI
The redirectUri passed to getAuthorizationToken does not match exactly (including trailing slashes) with Apple Console configuration.
fixVerify registered redirect URIs in Apple Developer; ensure case and path match exactly.
Error: The token is not valid or has expired
The verification fails because token is expired, signed with wrong key, or audience does not match clientID.
fixEnsure you are using the correct id_token (from latest token exchange) and that clientID matches the intended audience. Refresh token if expired.
Error: Cannot find module 'apple-signin'
Package not installed or not in node_modules.
fixRun 'npm install apple-signin' in your project directory.
Audit
Dependencies
jsonwebtokenrequiredUsed to sign client secrets and verify ID tokens (JWT operations).
node-joserequiredMay be used for JWT handling or key processing (depending on version).