Skip to main content

Integrating Auth0

Creating an account on Auth0

  • Go to the Auth0 website and create an account if you don't already have one.

Creating an application on Auth0

  • After logging in to Auth0, go to your dashboard and create a new application.

Create Application

  • Choose the type of application: "Regular Web Application".

Application Type

  • After creating the application, go to the "Settings" section of the application.

Settings

  • First of all, you will need to get the Channel Token from the Settings / Integrations / Teyuto API section.

Channel Token

  • Configure application settings, including callback URLs and logout URLs, by following these instructions:

Configuration

  • Configure the parameters like this:

    1. Application Login URI: https://$channelDomain/login
    2. Allowed Callback URLs: https://api.teyuto.tv/v2/oauth/YOUR_CHANNEL_TOKEN/check/auth0
      YOUR_CHANNEL_TOKEN is the parameter previously retrieved from the Settings / Integrations / Teyuto API section.
    3. Allowed Logout URLs: https://$channelDomain
    4. Make sure that "Allow Cross-Origin Authentication” is enabled.

Migrate Teyuto users to Auth0 progressively

If you have an active platform, it will be essential to follow these steps to allow your current users to be able to access through Auth0. Be very careful; if you do not take this step, your current users will not be able to access the platform.

To set up the Teyuto to Auth0 user migration integration, follow these steps:

  • Access the “Authentication” section in Auth0, then proceed with “+ Create DB Connection”.

Create DB Connection

  • Insert "teyuto-db” as the Database Name, and then click “Create”.

Create Database

  • Once the database has been created, from the “Settings” section, enable the “Import Users to Auth0”.

Import Users

  • Next, go to the “Custom Database” and enable the “Use my own database”.

Use Own Database

  • Still in the Custom Database section, scroll down to the "Database Action Scripts”.

  • For "Login", insert the code below in this way, being careful to change the parameter {channelToken} with your parameter recently found from the Settings / Integrations / Teyuto API section. Insert the Channel Token parameter into "YOUR_CHANNEL_TOKEN".

function login(email, password, callback) {
const channelToken = "YOUR_CHANNEL_TOKEN";
const request = require('request');
const jsonStringified = `email=${email}&password=${password}&twofa_required=false&is_external=true`;

request.get({
url: 'https://api.teyuto.tv/v2/sessions/authentication?' + jsonStringified,
headers: {
'channel': channelToken
},
// For more options check:
// https://github.com/mikeal/request#requestoptions-callback
}, function(err, response, body) {
if (err) return callback(err);
if (response.statusCode === 401) return callback();
const user = JSON.parse(body);

callback(null, {
email: email,
user_id: user.id.toString()
});
});
}
  • Then save; you should get a similar result:

Login Script

  • For "Get User", you will have to find "Auth Token" of Teyuto from your dashboard (it is the private token). Then go to the Settings / Integrations / Teyuto API section.

Auth Token

  • Now go back to Auth0 in the “Database Action Scripts” screen for “Get User”, and insert the Auth Token parameter into "YOUR_AUTH_TOKEN".
function loginByEmail(email, callback) {
const request = require('request');
const authToken = "YOUR_AUTH_TOKEN";

request.get({
url: 'https://api.teyuto.tv/v2/users?email=' + email,
headers: {
'Authorization': authToken
}
},

function (err, response, body) {
if (err) return callback(null);
if (response.statusCode === 404) return callback(null);

const user = JSON.parse(body);
const userObj = user.users[0];

callback(null, {
user_id: userObj.id.toString(),
nickname: userObj.username,
email: userObj.email
});
});
}
  • Then save; you should get a similar result:

Get User Script

Add integration in Teyuto

  • Access the Settings section and then Integrations.
  • Then search for "Auth0".

Search Auth0

  • Click on Connect.

Connect Auth0

  • From the Settings section of your Auth0 application, find the information to be entered into Teyuto.

Auth0 Settings

  • On the Teyuto integration screen, click on Connect.

Connect Teyuto