认证
Last updated
Last updated
Rememberizer 提供了多个认证端点来管理用户账户和会话。本文档概述了可用的认证 API。
curl -X POST \
https://api.rememberizer.ai/api/v1/auth/signup/ \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "secure_password",
"name": "John Doe",
"captcha": "recaptcha_response"
}'
将 recaptcha_response
替换为实际的 reCAPTCHA 响应。
const signUp = async () => {
const response = await fetch('https://api.rememberizer.ai/api/v1/auth/signup/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'user@example.com',
password: 'secure_password',
name: 'John Doe',
captcha: 'recaptcha_response'
})
});
const data = await response.json();
console.log(data);
};
signUp();
将 recaptcha_response
替换为实际的 reCAPTCHA 响应。
import requests
import json
def sign_up():
headers = {
"Content-Type": "application/json"
}
payload = {
"email": "user@example.com",
"password": "secure_password",
"name": "John Doe",
"captcha": "recaptcha_response"
}
response = requests.post(
"https://api.rememberizer.ai/api/v1/auth/signup/",
headers=headers,
data=json.dumps(payload)
)
data = response.json()
print(data)
sign_up()
将 recaptcha_response
替换为实际的 reCAPTCHA 响应。
curl -X POST \
https://api.rememberizer.ai/api/v1/auth/signin/ \
-H "Content-Type: application/json" \
-d '{
"login": "user@example.com",
"password": "secure_password",
"captcha": "recaptcha_response"
}'
将 recaptcha_response
替换为实际的 reCAPTCHA 响应。
const signIn = async () => {
const response = await fetch('https://api.rememberizer.ai/api/v1/auth/signin/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
login: 'user@example.com',
password: 'secure_password',
captcha: 'recaptcha_response'
})
});
// 检查响应中的身份验证 cookie
if (response.status === 204) {
console.log("登录成功!");
} else {
console.error("登录失败!");
}
};
signIn();
将 recaptcha_response
替换为实际的 reCAPTCHA 响应。
import requests
import json
def sign_in():
headers = {
"Content-Type": "application/json"
}
payload = {
"login": "user@example.com",
"password": "secure_password",
"captcha": "recaptcha_response"
}
response = requests.post(
"https://api.rememberizer.ai/api/v1/auth/signin/",
headers=headers,
data=json.dumps(payload)
)
if response.status_code == 204:
print("登录成功!")
else:
print("登录失败!")
sign_in()
将 recaptcha_response
替换为实际的 reCAPTCHA 响应。
curl -X POST \
https://api.rememberizer.ai/api/v1/auth/verify-email/ \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"verification_code": "123456"
}'
将 YOUR_JWT_TOKEN
替换为您的实际 JWT 令牌,并使用发送到您电子邮件的验证代码。
const verifyEmail = async () => {
const response = await fetch('https://api.rememberizer.ai/api/v1/auth/verify-email/', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_JWT_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
verification_code: '123456'
})
});
if (response.status === 200) {
console.log("电子邮件验证成功!");
} else {
console.error("电子邮件验证失败!");
}
};
verifyEmail();
将 YOUR_JWT_TOKEN
替换为您的实际 JWT 令牌,并使用发送到您电子邮件的验证代码。
import requests
import json
def verify_email():
headers = {
"Authorization": "Bearer YOUR_JWT_TOKEN",
"Content-Type": "application/json"
}
payload = {
"verification_code": "123456"
}
response = requests.post(
"https://api.rememberizer.ai/api/v1/auth/verify-email/",
headers=headers,
data=json.dumps(payload)
)
if response.status_code == 200:
print("电子邮件验证成功!")
else:
print("电子邮件验证失败!")
verify_email()
将 YOUR_JWT_TOKEN
替换为您的实际 JWT 令牌,并使用发送到您电子邮件的验证代码。
curl -X POST \
https://api.rememberizer.ai/api/v1/auth/custom-refresh/ \
-b "refresh_token=YOUR_REFRESH_TOKEN"
此端点使用 cookies 进行身份验证。刷新令牌应作为 cookie 发送。
const refreshToken = async () => {
const response = await fetch('https://api.rememberizer.ai/api/v1/auth/custom-refresh/', {
method: 'POST',
credentials: 'include' // 这将包括请求中的 cookies
});
if (response.status === 204) {
console.log("令牌成功刷新!");
} else {
console.error("令牌刷新失败!");
}
};
refreshToken();
此端点使用 cookies 进行身份验证。确保您的应用程序在请求中包含凭据。
import requests
def refresh_token():
cookies = {
"refresh_token": "YOUR_REFRESH_TOKEN"
}
response = requests.post(
"https://api.rememberizer.ai/api/v1/auth/custom-refresh/",
cookies=cookies
)
if response.status_code == 204:
print("令牌成功刷新!")
else:
print("令牌刷新失败!")
refresh_token()
将 YOUR_REFRESH_TOKEN
替换为您的实际刷新令牌。
curl -X POST \
https://api.rememberizer.ai/api/v1/auth/custom-logout/
此端点将清除身份验证 cookies。
const logout = async () => {
const response = await fetch('https://api.rememberizer.ai/api/v1/auth/custom-logout/', {
method: 'POST',
credentials: 'include' // 这将包括请求中的 cookies
});
if (response.status === 204) {
console.log("注销成功!");
} else {
console.error("注销失败!");
}
};
logout();
此端点使用 cookies 进行身份验证。确保您的应用程序在请求中包含凭据。
import requests
def logout():
session = requests.Session()
response = session.post(
"https://api.rememberizer.ai/api/v1/auth/custom-logout/"
)
if response.status_code == 204:
print("注销成功!")
else:
print("注销失败!")
logout()
此端点将清除身份验证 cookies。
{% endtabs %