Gathering detailed insights and metrics for @oqton/auth0-spa-js
Gathering detailed insights and metrics for @oqton/auth0-spa-js
npm install @oqton/auth0-spa-js
Typescript
Module System
Node Version
NPM Version
75.8
Supply Chain
98.7
Quality
80.9
Maintenance
100
Vulnerability
100
License
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Total Downloads
13,258
Last Day
18
Last Week
88
Last Month
538
Last Year
7,153
Latest Version
2.0.4-3
Package Id
@oqton/auth0-spa-js@2.0.4-3
Unpacked Size
1.10 MB
Size
290.36 kB
File Count
60
NPM Version
9.5.0
Node Version
18.15.0
Published on
May 15, 2023
Cumulative downloads
Total Downloads
Last Day
63.6%
18
Compared to previous day
Last Week
-46.7%
88
Compared to previous week
Last Month
26.6%
538
Compared to previous month
Last Year
17.2%
7,153
Compared to previous year
50
📚 Documentation - 🚀 Getting Started - 💻 API Reference - 💬 Feedback
Using npm in your project directory run the following command:
1npm install @auth0/auth0-spa-js
From the CDN:
1<script src="https://cdn.auth0.com/js/auth0-spa-js/2.0/auth0-spa-js.production.js"></script>
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.
- Ensure that "Token Endpoint Authentication Method" under "Application Properties" is set to "None"
- 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:
http://localhost:3000
http://localhost:3000
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.
Create an Auth0Client
instance before rendering or initializing your application. You should only have one instance of the client.
1import { createAuth0Client } from '@auth0/auth0-spa-js'; 2 3//with async/await 4const auth0 = await createAuth0Client({ 5 domain: '<AUTH0_DOMAIN>', 6 clientId: '<AUTH0_CLIENT_ID>', 7 authorizationParams: { 8 redirect_uri: '<MY_CALLBACK_URL>' 9 } 10}); 11 12//or, you can just instantiate the client on it's own 13import { Auth0Client } from '@auth0/auth0-spa-js'; 14 15const auth0 = new Auth0Client({ 16 domain: '<AUTH0_DOMAIN>', 17 clientId: '<AUTH0_CLIENT_ID>', 18 authorizationParams: { 19 redirect_uri: '<MY_CALLBACK_URL>' 20 } 21}); 22 23//if you do this, you'll need to check the session yourself 24try { 25 await auth0.getTokenSilently(); 26} catch (error) { 27 if (error.error !== 'login_required') { 28 throw error; 29 } 30}
You can then use login using the Auth0Client
instance you created:
1<button id="login">Click to Login</button>
1//redirect to the Universal Login Page 2document.getElementById('login').addEventListener('click', async () => { 3 await auth0.loginWithRedirect(); 4}); 5 6//in your callback route (<MY_CALLBACK_URL>) 7window.addEventListener('load', async () => { 8 const redirectResult = await auth0.handleRedirectCallback(); 9 //logged in. you can get the user profile like this: 10 const user = await auth0.getUser(); 11 console.log(user); 12});
For other comprehensive examples, see the EXAMPLES.md document.
Explore API Methods available in auth0-spa-js.
We appreciate feedback and contribution to this repo! Before you get started, please see the following:
To provide feedback or report a bug, please raise an issue on our issue tracker.
Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.
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.
No vulnerabilities found.
No security vulnerabilities found.