Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Shayan Memari ShayMe21

🏠
Working from home
View GitHub Profile
@ShayMe21
ShayMe21 / update_user_name_samlp_rule.js
Created Jul 12, 2019
Auth0 Update SAML IdP user's name
View update_user_name_samlp_rule.js
function (user, context, callback) {
var ManagementClient = require('auth0@2.9.1').ManagementClient;
let saml_name = `${user.first_name} ${user.last_name}`;
console.log(saml_name);
user.name = saml_name;
var management = new ManagementClient({
@ShayMe21
ShayMe21 / auth0.service.ts
Created May 16, 2019
Auth0 Angular2+ ParseHash with error handling of rules
View auth0.service.ts
public handleAuthentication(): void {
this.auth0.parseHash({}, (err, authResult) => {
if (authResult && authResult.accessToken && authResult.idToken) {
this.localLogin(authResult);
this.auth0.client.userInfo(authResult.accessToken, function (err, user) {
localStorage.setItem("user_id", user.sub);
});
this.router.navigate(['/home']);
@ShayMe21
ShayMe21 / get_user.js
Created Mar 27, 2019
Auth0 SQL Server Custom DB Get User script
View get_user.js
function getByEmail(email, callback) {
//this example uses the "tedious" library
//more info here: http://pekim.github.io/tedious/index.html
const sqlserver = require('tedious@1.11.0');
const Connection = sqlserver.Connection;
const Request = sqlserver.Request;
const TYPES = sqlserver.TYPES;
var user_profile = [];
@ShayMe21
ShayMe21 / auth0js-parseHash-angular.ts
Created Mar 11, 2019
Auth0.js ParseHash detect state missing error check and redirect. This can happen when a user bookmarks the hosted login page or keeps the page open for 30minutes+
View auth0js-parseHash-angular.ts
public handleAuthentication(): void {
this.auth0.parseHash({
}, (err, authResult) => {
if (authResult && authResult.accessToken && authResult.idToken) {
console.log(authResult);
this.localLogin(authResult);
this.auth0.client.userInfo(authResult.accessToken, function (err, user) {
localStorage.setItem("user_id", user.sub);
console.log(user.sub);
View Auth0 .Net Core Get management API Token.cs
// https://auth0.github.io/auth0.net/index.html
// https://auth0.github.io/auth0.net/api/Auth0.AuthenticationApi.Models.ClientCredentialsTokenRequest.html
public async void getapi2token(){
var AuthAPI = new AuthenticationApiClient(new Uri("https://shayan-dev.au.auth0.com/"));
var api2Response = await AuthAPI.GetTokenAsync(new ClientCredentialsTokenRequest
{
ClientId = "43BKVc57RgIiVJrbM8gRDIBQgofdByYe",
ClientSecret = "xxx",
View auth0-api2-python.jpy
###--------Modules-------------------------------------------------------------#
import requests
import json
###--------Functions-----------------------------------------------------------#
clientId="nNVpnD0SxI1GI87ZvNiMOn1MOaWXw3gp"
clientSecret="--"
url="shayanmemari.au.auth0.com"
customer="testing-BFP1"
@ShayMe21
ShayMe21 / hlp.html
Created Oct 1, 2018
auth0-hosted-login-added-passwordless-option
View hlp.html
<!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" />
</head>
<body>
<button id="lock_button">Lock</button>
@ShayMe21
ShayMe21 / MyViewController.cs
Created Jul 31, 2018
Xamarin with Auth0 and TouchID Authentication
View MyViewController.cs
// https://github.com/auth0-community/auth0-xamarin-oidc-samples/tree/master/Quickstart/01-Login/iOS
using System;
using UIKit;
using Auth0.OidcClient;
using System.Text;
using LocalAuthentication;
using Foundation;
using Xamarin.Auth;