Skip to content

auth0/auth0-spa-js

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

…1220)

Bumps
[browserstack-cypress-cli](https://github.com/browserstack/browserstack-cypress-cli)
from 1.27.0 to 1.28.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/browserstack/browserstack-cypress-cli/releases">browserstack-cypress-cli's
releases</a>.</em></p>
<blockquote>
<h2>Public Beta v1.28.0</h2>
<p>Highlighted Changes 🥳</p>
<ul>
<li>
<p>❇️ Support for running cypress sessions on Automate Turboscale. <a
href="https://redirect.github.com/browserstack/browserstack-cypress-cli/pull/736">browserstack/browserstack-cypress-cli#736</a></p>
</li>
<li>
<p>🐛 Fix specs array case for enforce_settings in mac. <a
href="https://redirect.github.com/browserstack/browserstack-cypress-cli/pull/762">browserstack/browserstack-cypress-cli#762</a></p>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/browserstack/browserstack-cypress-cli/commit/cfa7e237c0d271c67992faf918aa412d534ad68b"><code>cfa7e23</code></a>
Merge pull request <a
href="https://redirect.github.com/browserstack/browserstack-cypress-cli/issues/767">#767</a>
from browserstack/deploy</li>
<li><a
href="https://github.com/browserstack/browserstack-cypress-cli/commit/b47531586c03fef9ef909c4fadce013feeb00760"><code>b475315</code></a>
1.28.0</li>
<li><a
href="https://github.com/browserstack/browserstack-cypress-cli/commit/89eaf8343900206ddd8769cd43af471078d3ba49"><code>89eaf83</code></a>
Merge pull request <a
href="https://redirect.github.com/browserstack/browserstack-cypress-cli/issues/736">#736</a>
from browserstack/HST_722_ats</li>
<li><a
href="https://github.com/browserstack/browserstack-cypress-cli/commit/a17f89cfcb6310b252f3e73505e446ec8fe74b94"><code>a17f89c</code></a>
Merge branch 'master' into HST_722_ats</li>
<li><a
href="https://github.com/browserstack/browserstack-cypress-cli/commit/5d419bcd022c33552101bf8ff77fa080142e5030"><code>5d419bc</code></a>
Merge pull request <a
href="https://redirect.github.com/browserstack/browserstack-cypress-cli/issues/762">#762</a>
from browserstack/APS_9240_Fix_MAC_Specs_Array_Enforc...</li>
<li><a
href="https://github.com/browserstack/browserstack-cypress-cli/commit/c3aed35c83987bb22e959ff28885672b76e73772"><code>c3aed35</code></a>
Merge branch 'HST_722_ats' of
github.com:browserstack/browserstack-cypress-cl...</li>
<li><a
href="https://github.com/browserstack/browserstack-cypress-cli/commit/49030875018d1abafe6cb2553663d021daa6a1c3"><code>4903087</code></a>
patch ats config</li>
<li><a
href="https://github.com/browserstack/browserstack-cypress-cli/commit/4c0ccb6a75637d64e030200b5151a6edf11e6155"><code>4c0ccb6</code></a>
Merge branch 'master' into HST_722_ats</li>
<li><a
href="https://github.com/browserstack/browserstack-cypress-cli/commit/e12b0431311427dd04bf2d0c28d22060459320ce"><code>e12b043</code></a>
Fix UT</li>
<li><a
href="https://github.com/browserstack/browserstack-cypress-cli/commit/c4609532f961dc98caddb365e8fa527bb680f925"><code>c460953</code></a>
Fix Specs Array Case for Enforce_Settings MAC</li>
<li>Additional commits viewable in <a
href="https://github.com/browserstack/browserstack-cypress-cli/compare/v1.27.0...v1.28.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=browserstack-cypress-cli&package-manager=npm_and_yarn&previous-version=1.27.0&new-version=1.28.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
b661137

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
December 11, 2023 13:11
August 18, 2022 10:43
src
December 11, 2023 13:11
April 9, 2019 23:26
December 11, 2023 13:11
December 11, 2023 13:11
December 11, 2023 13:11
April 9, 2019 23:26
August 18, 2022 10:43

Auth0 SDK for Single Page Applications using Authorization Code Grant Flow with PKCE.

Release Codecov Downloads License CircleCI

📚 Documentation - 🚀 Getting Started - 💻 API Reference - 💬 Feedback

Documentation

  • Quickstart - our interactive guide for quickly adding login, logout and user information to your app using Auth0.
  • Sample app - a full-fledged sample app integrated with Auth0.
  • FAQs - frequently asked questions about auth0-spa-js SDK.
  • Examples - code samples for common scenarios.
  • Docs Site - explore our Docs site and learn more about Auth0.

Getting Started

Installation

Using npm in your project directory run the following command:

npm install @auth0/auth0-spa-js

From the CDN:

<script src="https://cdn.auth0.com/js/auth0-spa-js/2.1/auth0-spa-js.production.js"></script>

Configure Auth0

Create a Single Page Application in the Auth0 Dashboard.

If you're using an existing application, verify that you have configured the following settings in your Single Page Application:

  • Click on the "Settings" tab of your application's page.
  • Scroll down and click on the "Show Advanced Settings" link.
  • Under "Advanced Settings", click on the "OAuth" tab.
  • Ensure that "JsonWebToken Signature Algorithm" is set to RS256 and that "OIDC Conformant" is enabled.

Next, configure the following URLs for your application under the "Application URIs" section of the "Settings" page:

  • Allowed Callback URLs: http://localhost:3000
  • Allowed Logout URLs: http://localhost:3000
  • Allowed Web Origins: http://localhost:3000

These URLs should reflect the origins that your application is running on. Allowed Callback URLs may also include a path, depending on where you're handling the callback (see below).

Take note of the Client ID and Domain values under the "Basic Information" section. You'll need these values in the next step.

Configure the SDK

Create an Auth0Client instance before rendering or initializing your application. You should only have one instance of the client.

import { createAuth0Client } from '@auth0/auth0-spa-js';

//with async/await
const auth0 = await createAuth0Client({
  domain: '<AUTH0_DOMAIN>',
  clientId: '<AUTH0_CLIENT_ID>',
  authorizationParams: {
    redirect_uri: '<MY_CALLBACK_URL>'
  }
});

//or, you can just instantiate the client on its own
import { Auth0Client } from '@auth0/auth0-spa-js';

const auth0 = new Auth0Client({
  domain: '<AUTH0_DOMAIN>',
  clientId: '<AUTH0_CLIENT_ID>',
  authorizationParams: {
    redirect_uri: '<MY_CALLBACK_URL>'
  }
});

//if you do this, you'll need to check the session yourself
try {
  await auth0.getTokenSilently();
} catch (error) {
  if (error.error !== 'login_required') {
    throw error;
  }
}

Logging In

You can then use login using the Auth0Client instance you created:

<button id="login">Click to Login</button>
//redirect to the Universal Login Page
document.getElementById('login').addEventListener('click', async () => {
  await auth0.loginWithRedirect();
});

//in your callback route (<MY_CALLBACK_URL>)
window.addEventListener('load', async () => {
  const redirectResult = await auth0.handleRedirectCallback();
  //logged in. you can get the user profile like this:
  const user = await auth0.getUser();
  console.log(user);
});

For other comprehensive examples, see the EXAMPLES.md document.

API Reference

Explore API Methods available in auth0-spa-js.

Feedback

Contributing

We appreciate feedback and contribution to this repo! Before you get started, please see the following:

Raise an issue

To provide feedback or report a bug, please raise an issue on our issue tracker.

Vulnerability Reporting

Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.

What is Auth0?

Auth0 Logo

Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout Why Auth0?

This project is licensed under the MIT license. See the LICENSE file for more info.