Search...
Menu

Generate Authorized Login Address (Verification code access)

PDF

The application scenarios are as follows:

The access rights of the site are set to verification code access, and you can use the examples provided by us (php, python, nodejs) to generate a link. You only need to guide the user to click the link to complete the visitor login authentication, thereby omitting the authentication process of receiving the verification code.

 

php example

<?php
$token = ''; // AI Integrations -> AI Token
$email = ''; // email
$timestamp = time(); // Current system timestamp (sec), used by us to control the expiration date of this link, the default expiration date is 1 month
$website = 'https://{Customized Domain Name}'; // Help Center Domain Name, https cannot be omitted

$secret = hash("sha256", $email . $phone . $timestamp . $token);
echo $website . "/access?email=$email&phone=$phone&timestamp=$timestamp&secret=$secret";

 

python example

import hashlib
import time

token = ''  # AI Integrations -> AI Token
email = ''  # email
timestamp = int(time.time())  # Current system timestamp (sec), used by us to control the expiration date of this link, the default expiration date is 1 month
website = 'https://{Customized Domain Name}'  # Help Center Domain Name,https cannot be omitted

secret = hashlib.sha256((email + phone + str(timestamp) + token).encode()).hexdigest()
print(website + f"/access?email={email}&phone={phone}&timestamp={timestamp}&secret={secret}")

 

nodejs example

const crypto = require('crypto');

const token = ''; // 设置->AI配置->AI Token
const email = ''; // 邮箱
const phone = ''; // 手机号
const timestamp = Math.floor(Date.now() / 1000); // 当前系统时间戳(秒) 用于我方控制此链接的有效期,默认有效期为1个月
const website = 'https://{自定义域名}'; // 帮助中心域名,https不能省略

const secret = crypto.createHash('sha256').update(email + phone + timestamp + token).digest('hex');
console.log(`${website}/access?email=${email}&phone=${phone}&timestamp=${timestamp}&secret=${secret}`);

 

 

Generated link example

https://{custom domain}/access?email=&phone=timestamp=1711357679&secret=653b37b44291f43298f7fa1290722f96cb20a7999d93c5f5ae1fb6329bb6ebd3

 

Share this Article
Last modified: 2024-04-03Powered by