Introducción a Auth0
¿Ya tomaste el Curso de Introducción a OAuth 2.0 y OIDC?
¿Qué es Auth0?
¿Qué es Universal Login?
Autenticación rápida con el SDK de Next.js
Conexiones sociales
¿Cómo hacer un login con GitHub?
¿Cómo hacer un login con Twitch?
¿Cómo hacer un login custom con Discord?
Conexiones sin password
¿Cómo implementar el login con SMS?
¿Cómo implementar el login con Email?
Protegiendo una API
¿Cómo usar la Auth0 Management API?
¿Cómo configurar una API en Auth0?
¿Cómo proteger un endpoint?
Auth0 SDKs
Single Page Apps: React SDK
Regular Web Apps: Express SDK
Machine to Machine: Express.js
Administración de usuarios
¿Cómo administrar usuarios?
¿Cómo administrar roles?
Reglas y Acciones en Auth0
¿Qué son las reglas y acciones en Auth0?
¿Cómo implementar una regla?
¿Cómo implementar una acción?
Multifactor Authentication
¿Qué es multifactor authentication?
WebAuthn con FIDO Security Keys
One-time Password
Casos en producción
Actividad y Monitoreo en Auth0
¿Cómo integrar Firebase Auth?
Implementación Firebase Auth: Admin
Implementación Firebase Auth: Rules
¿Quieres más cursos de autenticación?
You don't have access to this class
Keep learning! Join and start boosting your career
Integrating a custom login with Discord may seem intimidating at first, but it's actually quite an accessible process. Using Auth0, a powerful platform for authentication, and the Discord API, you can allow users to sign in and access your application using their Discord accounts.
To perform this integration, you first need to create a new connection in Auth0:
Both URLs are crucial, and can be located in Discord's OAuth documentation.
You must access the Discord developer portal:
These credentials are critical for authentication on Discord.
When working with authentication APIs, the concept of "scopes" is vital. In the case of Discord, you must configure the following permissions to obtain the user's information:
Always check the necessary scopes in the OAuth documentation of the service you are going to integrate.
To fetch and handle user profile data from Discord, a specific script is required:
const request = require('request');
function FetchDiscordUser(accessToken, context, callback) { const API_URL = 'https://discord.com/api/v10'; const CDN_URL = 'https://cdn.discordapp.com';
request.get({ url: `${API_URL}/users/@me`, headers: { 'Authorization': `Bearer ${accessToken}`, }, }, }, function(err, response, body) { if (err || response.statusCode !== 200) { return callback(new Error('Error getting Discord user')); }
try { const jsonResponse = JSON.parse(body); const profile = { id: jsonResponse.id, name: `${jsonResponse.username}#${jsonResponse.discriminator}`, nickname: jsonResponse.username, picture: `${CDN_URL}/avatars/${jsonResponse.id}/${jsonResponse.avatar}.png` };
callback(null, profile); } catch (e) { callback(new Error('Error parsing JSON')); } } });}}
module.exports = FetchDiscordUser;
This script uses the latest version of the Discord API to ensure that you handle user data correctly. Installation of packages such as request
may be necessary.
It is critical to verify that the redirect URL is set up correctly. This URL is essential to complete the OAuth flow and must match:
https://yourtenant.auth0.com/login/callback.
Be sure to save the changes in Discord and return to Auth0 to test the connection.
Once Discord is configured, I encourage you to explore other services that implement OAuth. By creating new custom connections to these services in Auth0, you will improve and expand your understanding of the authentication flow. Keep experimenting and learning about this crucial aspect of modern development!
Contributions 0
Questions 1
Want to see more contributions, questions and answers from the community?