{"id":15371596,"url":"https://github.com/stevehobbsdev/auth0-spa-js-shim","last_synced_at":"2026-03-18T00:30:17.899Z","repository":{"id":143406365,"uuid":"236014371","full_name":"stevehobbsdev/auth0-spa-js-shim","owner":"stevehobbsdev","description":null,"archived":false,"fork":false,"pushed_at":"2020-01-24T14:20:26.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-31T20:15:58.490Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stevehobbsdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-24T14:09:49.000Z","updated_at":"2020-01-24T14:20:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"ff54410a-209f-41fc-b975-6731d83842c0","html_url":"https://github.com/stevehobbsdev/auth0-spa-js-shim","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"b1a58606018428a858cbc64bc3bdea54dfbe759c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevehobbsdev%2Fauth0-spa-js-shim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevehobbsdev%2Fauth0-spa-js-shim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevehobbsdev%2Fauth0-spa-js-shim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevehobbsdev%2Fauth0-spa-js-shim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stevehobbsdev","download_url":"https://codeload.github.com/stevehobbsdev/auth0-spa-js-shim/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239929397,"owners_count":19720123,"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":[],"created_at":"2024-10-01T13:47:58.206Z","updated_at":"2026-03-18T00:30:17.861Z","avatar_url":"https://github.com/stevehobbsdev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @auth0/auth0-spa-js\n\nAuth0 SDK for Single Page Applications using [Authorization Code Grant Flow with PKCE](https://auth0.com/docs/api-auth/tutorials/authorization-code-grant-pkce).\n\n[![CircleCI](https://circleci.com/gh/auth0/auth0-spa-js.svg?style=svg)](https://circleci.com/gh/auth0/auth0-spa-js)\n[![License](https://img.shields.io/:license-mit-blue.svg?style=flat)](https://opensource.org/licenses/MIT)\n\n## Table of Contents\n\n- [Documentation](#documentation)\n- [Installation](#installation)\n- [Getting Started](#getting-started)\n- [Contributing](#contributing)\n- [Support + Feedback](#support--feedback)\n- [Frequently Asked Questions](#frequently-asked-questions)\n- [Vulnerability Reporting](#vulnerability-reporting)\n- [What is Auth0](#what-is-auth0)\n- [License](#license)\n\n## Documentation\n\n- [Documentation](https://auth0.com/docs/libraries/auth0-spa-js)\n- [API reference](https://auth0.github.io/auth0-spa-js/)\n- [Migrate from Auth0.js to the Auth0 Single Page App SDK](https://auth0.com/docs/libraries/auth0-spa-js/migrate-from-auth0js)\n\n## Installation\n\nFrom the CDN:\n\n```html\n\u003cscript src=\"https://cdn.auth0.com/js/auth0-spa-js/1.2/auth0-spa-js.production.js\"\u003e\u003c/script\u003e\n```\n\nUsing [npm](https://npmjs.org):\n\n```sh\nnpm install @auth0/auth0-spa-js\n```\n\nUsing [yarn](https://yarnpkg.com):\n\n```sh\nyarn add @auth0/auth0-spa-js\n```\n\n## Getting Started\n\n### Creating the client\n\nCreate an `Auth0Client` instance before rendering or initializing your application. You should only have one instance of the client.\n\n```js\nimport createAuth0Client from '@auth0/auth0-spa-js';\n\n//with async/await\nconst auth0 = await createAuth0Client({\n  domain: '\u003cAUTH0_DOMAIN\u003e',\n  client_id: '\u003cAUTH0_CLIENT_ID\u003e',\n  redirect_uri: '\u003cMY_CALLBACK_URL\u003e'\n});\n\n//with promises\ncreateAuth0Client({\n  domain: '\u003cAUTH0_DOMAIN\u003e',\n  client_id: '\u003cAUTH0_CLIENT_ID\u003e',\n  redirect_uri: '\u003cMY_CALLBACK_URL\u003e'\n}).then(auth0 =\u003e {\n  //...\n});\n```\n\n### 1 - Login\n\n```html\n\u003cbutton id=\"login\"\u003eClick to Login\u003c/button\u003e\n```\n\n```js\n//with async/await\n\n//redirect to the Universal Login Page\ndocument.getElementById('login').addEventListener('click', async () =\u003e {\n  await auth0.loginWithRedirect();\n});\n\n//in your callback route (\u003cMY_CALLBACK_URL\u003e)\nwindow.addEventListener('load', async () =\u003e {\n  const redirectResult = await auth0.handleRedirectCallback();\n  //logged in. you can get the user profile like this:\n  const user = await auth0.getUser();\n  console.log(user);\n});\n\n//with promises\n\n//redirect to the Universal Login Page\ndocument.getElementById('login').addEventListener('click', () =\u003e {\n  auth0.loginWithRedirect().catch(() =\u003e {\n    //error while redirecting the user\n  });\n});\n\n//in your callback route (\u003cMY_CALLBACK_URL\u003e)\nwindow.addEventListener('load', () =\u003e {\n  auth0.handleRedirectCallback().then(redirectResult =\u003e {\n    //logged in. you can get the user profile like this:\n    auth0.getUser().then(user =\u003e {\n      console.log(user);\n    });\n  });\n});\n```\n\n### 2 - Calling an API\n\n```html\n\u003cbutton id=\"call-api\"\u003eCall an API\u003c/button\u003e\n```\n\n```js\n//with async/await\ndocument.getElementById('call-api').addEventListener('click', async () =\u003e {\n  const accessToken = await auth0.getTokenSilently();\n  const result = await fetch('https://myapi.com', {\n    method: 'GET',\n    headers: {\n      Authorization: `Bearer ${accessToken}`\n    }\n  });\n  const data = await result.json();\n  console.log(data);\n});\n\n//with promises\ndocument.getElementById('call-api').addEventListener('click', () =\u003e {\n  auth0\n    .getTokenSilently()\n    .then(accessToken =\u003e\n      fetch('https://myapi.com', {\n        method: 'GET',\n        headers: {\n          Authorization: `Bearer ${accessToken}`\n        }\n      })\n    )\n    .then(result =\u003e result.json())\n    .then(data =\u003e {\n      console.log(data);\n    });\n});\n```\n\n### 3 - Logout\n\n```html\n\u003cbutton id=\"logout\"\u003eLogout\u003c/button\u003e\n```\n\n```js\nimport createAuth0Client from '@auth0/auth0-spa-js';\n\ndocument.getElementById('logout').addEventListener('click', () =\u003e {\n  auth0.logout();\n});\n```\n\n## Contributing\n\nWe appreciate feedback and contribution to this repo! Before you get started, please see the following:\n\n- [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)\n- [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)\n- [This repo's contribution guide](https://github.com/auth0/auth0-spa-js/blob/master/CONTRIBUTING.md)\n\n## Support + Feedback\n\nThis SDK is in Early Access with selected stakeholders.\n\nWe process feedback and provide support via private channels.\n\n## Frequently Asked Questions\n\nFor a rundown of common issues you might encounter when using the SDK, please check out [the FAQ](https://github.com/auth0/auth0-spa-js/blob/master/FAQ.md).\n\n## Vulnerability Reporting\n\nPlease do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues.\n\n## What is Auth0?\n\nAuth0 helps you to easily:\n\n- implement authentication with multiple identity providers, including social (e.g., Google, Facebook, Microsoft, LinkedIn, GitHub, Twitter, etc), or enterprise (e.g., Windows Azure AD, Google Apps, Active Directory, ADFS, SAML, etc.)\n- log in users with username/password databases, passwordless, or multi-factor authentication\n- link multiple user accounts together\n- generate signed JSON Web Tokens to authorize your API calls and flow the user identity securely\n- access demographics and analytics detailing how, when, and where users are logging in\n- enrich user profiles from other data sources using customizable JavaScript rules\n\n[Why Auth0?](https://auth0.com/why-auth0)\n\n## License\n\nThis project is licensed under the MIT license. See the [LICENSE](https://github.com/auth0/auth0-spa-js/blob/master/LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevehobbsdev%2Fauth0-spa-js-shim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstevehobbsdev%2Fauth0-spa-js-shim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevehobbsdev%2Fauth0-spa-js-shim/lists"}