{"id":24914095,"url":"https://github.com/techofficer/node-apple-signin","last_synced_at":"2025-10-17T00:31:55.639Z","repository":{"id":48379099,"uuid":"191624316","full_name":"Techofficer/node-apple-signin","owner":"Techofficer","description":"Node.JS wrapper around Sign In with Apple REST API","archived":false,"fork":false,"pushed_at":"2023-01-19T15:28:55.000Z","size":31,"stargazers_count":53,"open_issues_count":15,"forks_count":40,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T21:18:57.315Z","etag":null,"topics":["apple","ios","node","node-js","nodejs","oauth","oauth2","oauth2-authentication","oauth2-client"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Techofficer.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-12T18:27:30.000Z","updated_at":"2024-05-14T02:57:15.000Z","dependencies_parsed_at":"2023-02-11T06:50:11.921Z","dependency_job_id":null,"html_url":"https://github.com/Techofficer/node-apple-signin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Techofficer%2Fnode-apple-signin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Techofficer%2Fnode-apple-signin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Techofficer%2Fnode-apple-signin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Techofficer%2Fnode-apple-signin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Techofficer","download_url":"https://codeload.github.com/Techofficer/node-apple-signin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236756743,"owners_count":19199897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apple","ios","node","node-js","nodejs","oauth","oauth2","oauth2-authentication","oauth2-client"],"created_at":"2025-02-02T06:16:25.430Z","updated_at":"2025-10-17T00:31:50.340Z","avatar_url":"https://github.com/Techofficer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Node.js] Sign in with Apple \n\nNode.JS wrapper around [Sign in with Apple REST API](https://developer.apple.com/documentation/signinwithapplerestapi).\n\nThis module lets you authenticate users using Apple account in your Node.js application.\n\n## Prerequisites\n1. You should be enrolled in [Apple Developer Program](https://developer.apple.com/programs/).\n2. Please have a look at [Apple documentation](\nhttps://developer.apple.com/sign-in-with-apple/get-started/) related to \"Sign in with Apple\" feature.\n3. You should create App ID and Service ID in your Apple Developer Account.\n4. You should generate private key for your Service ID in your Apple Developer Account.\n\nMore detail about configuration can be found in [blog post](https://medium.com/@artyomefremov/add-sign-in-with-apple-button-to-your-website-today-part-1-12ed1444623a?postPublishedType=initial) and [Apple docs](https://help.apple.com/developer-account/#/dev1c0e25352).\n\n## Installation\n\nInstall the module using [npm](http://npmjs.com):\n\n```bash\nnpm install --save apple-signin\n```\n\n## Usage\n\n### 1. Get authorization URL\nStart \"Sign in with Apple\" flow by redirecting user to the authorization URL.\n```javascript\nconst appleSignin = require(\"apple-signin\");\n\nconst options = {\n    clientID: \"com.gotechmakers.auth.client\", // identifier of Apple Service ID.\n    redirectUri: \"http://localhost:3000/auth/apple/callback\",\n    state: \"123\", // optional, An unguessable random string. It is primarily used to protect against CSRF attacks.\n    scope: \"email\" // optional, default value is \"email\".\n};\n\nconst authorizationUrl = appleSignin.getAuthorizationUrl(options);\n```\nAlternatively, you can use [Sign In with Apple](https://developer.apple.com/documentation/signinwithapplejs) browser javascript library.\n\n### 2. Get access token\n2.1. Retrieve \"code\" query param from URL string when user is redirected to your site after successful sign in with Apple. Example:\nhttp://localhost:3000/auth/apple/callback?code=somecode\u0026state=123.\n\n2.2. Exchange retrieved \"code\" to user's access token.\n\nMore detail can be found in [Apple docs](https://developer.apple.com/documentation/signinwithapplerestapi/generate_and_validate_tokens).\n\n```javascript\n\nconst clientSecret = appleSignin.getClientSecret({\n    clientID: \"com.gotechmakers.auth.client\", // identifier of Apple Service ID.\n    teamId: \"teamId\", // Apple Developer Team ID.\n    privateKeyPath: \"/var/www/app/AuthKey_XXX.p8\", // path to private key associated with your client ID.\n    keyIdentifier: \"XXX\" // identifier of the private key.    \n});\n\nconst options = {\n    clientID: \"com.gotechmakers.auth.client\", // identifier of Apple Service ID.\n    redirectUri: \"http://localhost:3000/auth/apple/callback\", // use the same value which you passed to authorisation URL.\n    clientSecret: clientSecret\n};\n \nappleSignin.getAuthorizationToken(code, options).then(tokenResponse =\u003e {\n    console.log(tokenResponse);\n}).catch(error =\u003e {\n    console.log(error);\n});\n```\n\nResult of ```getAuthorizationToken``` command is a JSON object representing Apple's [TokenResponse](https://developer.apple.com/documentation/signinwithapplerestapi/tokenresponse):\n```javascript\n{\n    access_token: \"ACCESS_TOKEN\", // A token used to access allowed data.\n    token_type: 'Bearer', // It will always be Bearer.\n    expires_in: 3600, // The amount of time, in seconds, before the access token expires.\n    refresh_token: \"REFRESH_TOKEN\", // used to regenerate new access tokens. Store this token securely on your server.\n    id_token: \"ID_TOKEN\" // A JSON Web Token that contains the user’s identity information.\n}\n```\n\n### 3. Verify token signature and get unique user's identifier\n```javascript\nappleSignin.verifyIdToken(tokenResponse.id_token, clientID).then(result =\u003e {\n    const userAppleId = result.sub;\n}).catch(error =\u003e {\n    // Token is not verified\n    console.log(error);\n});\n```\n### 4. Refresh access token after expiration\n```javascript\n\nconst clientSecret = appleSignin.getClientSecret({\n    clientID: \"com.gotechmakers.auth.client\", // identifier of Apple Service ID.\n    teamId: \"teamId\", // Apple Developer Team ID.\n    privateKeyPath: \"/var/www/app/AuthKey_XXX.p8\", // path to private key associated with your client ID.\n    keyIdentifier: \"XXX\" // identifier of the private key.    \n});\n\nconst options = {\n    clientID: \"com.gotechmakers.auth.client\", // identifier of Apple Service ID.\n    clientSecret: clientSecret\n};\n \nappleSignin.refreshAuthorizationToken(refreshToken, options).then(result =\u003e {\n    const newAccessToken = result.access_token;\n}).catch(error =\u003e {\n    console.log(error);\n})\n```\n\n## Examples\nDevelopers using the popular [Express](http://expressjs.com) web framework can refer to an [example](https://github.com/Techofficer/express-apple-signin) as a starting point for their own web applications. \n\nYou can also check [live example](http://apple-auth.gotechmakers.com)\n\n## Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\n## License\n[The MIT License](https://choosealicense.com/licenses/mit/)\n\nCopyright (c) 2019 Artem Efremov \u003chttps://gotechmakers.com\u003e\n\n## Support\nIf you have any questions or need help with integration, then you can contact me by email [efremov.artserg@gmail.com](efremov.artserg@gmail.com).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechofficer%2Fnode-apple-signin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechofficer%2Fnode-apple-signin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechofficer%2Fnode-apple-signin/lists"}