auth0/auth0.js

Name: auth0.js

Owner: Auth0

Description: Auth0 headless browser sdk

Created: 2013-09-26 15:15:07.0

Updated: 2018-01-11 23:01:40.0

Pushed: 2018-01-17 16:02:15.0

Homepage: null

Size: 11072

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

auth0.js

Build Status NPM version Coverage License Downloads

Client Side Javascript toolkit for Auth0 API

Auth0.js v9 uses our latest embedded login API. This version cannot be used inside Auth0-Hosted Login Pages. If you are using a Hosted Login Page, keep using Auth0.js v8.

Need help migrating from v8? Please check our Migration Guide

If you want to read the full API documentation of auth0.js, see here

Install

From CDN

 Latest patch release -->
ipt src="https://cdn.auth0.com/js/auth0/9.2.2/auth0.min.js"></script>

From npm

install auth0-js

After installing the auth0-js module, you'll need bundle it up along with all of its dependencies.

auth0.WebAuth

Provides support for all the authentication flows

Initialize
auth0 = new auth0.WebAuth({
main: "{YOUR_AUTH0_DOMAIN}",
ientID: "{YOUR_AUTH0_CLIENT_ID}"

Parameters:

API
0.authorize({
dience: 'https://mystore.com/api/v2',
ope: 'read:order write:order',
sponseType: 'token',
directUri: 'https://example.com/auth/callback'

This method requires that your tokens are signed with RS256. Please check our Migration Guide for more information.

0.parseHash({ hash: window.location.hash }, function(err, authResult) {
 (err) {
return console.log(err);


 The contents of authResult depend on which authentication parameters were used.
 It can include the following:
 authResult.accessToken - access token for the API specified by `audience`
 authResult.expiresIn - string with the access token's expiration time in seconds
 authResult.idToken - ID token JWT containing user profile information

th0.client.userInfo(authResult.accessToken, function(err, user) {
// Now you have the user's information
;

0.checkSession({
dience: 'https://mystore.com/api/v2',
ope: 'read:order write:order'
 function (err, authResult) {
// Authentication tokens or error

The contents of authResult are identical to those returned by parseHash().

Important: If you're not using the hosted login page to do social logins, you have to use your own social connection keys. If you use Auth0's dev keys, you'll always get login_required as an error when calling checkSession.

Important: Because there is no redirect in this method, responseType: 'code' is not supported and will throw an error.

Remember to add the URL where the authorization request originates from, to the Allowed Web Origins list of your Auth0 client in the Dashboard under your client's Settings.

0.client.login({
alm: 'Username-Password-Authentication', //connection name or HRD domain
ername: 'info@auth0.com',
ssword: 'areallystrongpassword',
dience: 'https://mystore.com/api/v2',
ope: 'read:order write:order',
 function(err, authResult) {
// Auth tokens in the result or an error

The contents of authResult are identical to those returned by parseHash().

auth0.Authentication

Provides an API client for the Auth0 Authentication API.

Initialize
auth0 = new auth0.Authentication({
main: "{YOUR_AUTH0_DOMAIN}",
ientID: "{YOUR_AUTH0_CLIENT_ID}"

API
auth0.Management

Provides an API Client for the Auth0 Management API (only methods meant to be used from the client with the user token).

Initialize
auth0 = new auth0.Management({
main: "{YOUR_AUTH0_DOMAIN}",
ken: "{YOUR_AUTH0_API_TOKEN}"

API
Documentation

For a complete reference and examples please check our docs and our Migration Guide if you need help to migrate from v7

Develop

Run npm start and point your browser to https://localhost:3000/example to run the example page.

Run npm run test to run the test suite.

Run npm run test:watch to run the test suite while you work.

Run npm run test:coverage to run the test suite with coverage report.

Run npm run lint to run the linter and check code styles.

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.

For auth0 related questions/support please use the Support Center.

Author

Auth0

License

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


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.