Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Sign In with Auth0</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Sign In with Auth0</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<style>
function (user, context, callback) {
const ManagementClient = require('[email protected]').ManagementClient;
var emailVerified = user && user.email_verified ? user.email_verified : false;
if (!emailVerified) {
var management = new ManagementClient({
token: auth0.accessToken,
domain: auth0.domain
});
var data = {
user_id: user.user_id
#Get token
curl --request POST \
--url 'https://[domain].auth0.com/oauth/token' \
-H 'content-type: application/json' \
-d '{"grant_type":"client_credentials","client_id": "[Client ID]","client_secret": "[Client Secret]","audience": "https://[domain].auth0.com/api/v2/"}'
#Retrieves all Guardian enrollments.
curl --request GET \
--url "https://[domain].auth0.com/api/v2/users/[User ID]/enrollments" \
#Create Dynamic Client
#create client
curl --request POST \
--url "https://[TENANT].auth0.com/oidc/register" \
--data '{ "client_name":"[Friendly name]", "redirect_uris":["http://localhost:4200"]}' \
--header "Content-Type: application/json" \
# Upgrade connection to domain level and enable client for the connection
curl --request PATCH \
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Sign In with Auth0</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<style>
function (user, context, callback) {
function daydiff (first, second) {
return (second-first)/(1000*60*60*24);
}
const last_password_change = user.last_password_reset || user.created_at;
if (daydiff(new Date(last_password_change), new Date()) > 30) {
return callback(new UnauthorizedError('please change your password'));
function (user, context, callback) {
  const namespace = 'https://myapi.com/';
  // console.log("Groups : "+user.groups);
  // console.log("Roles : "+user.roles);
//console.log("Permissions : "+user.permissions);
// attaching claim in idToken
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace ClientCredentials {
class Program {
function (user, context, callback) {
var request = require("request");
var count = context.stats && context.stats.loginsCount ? context.stats.loginsCount : 0;
if (count > 1) {
return callback(null, user, context);
}
var headers = {
'Authorization': 'Bearer ' + auth0.accessToken,