控制台
身份验证

身份验证概述

应用程序用户的项目范围身份。

项目身份验证是应用程序用户身份层。每个项目都会收到自己的可发布密钥、用户、身份、会话、签名密钥、重定向策略、电子邮件传送和 OAuth 应用程序。

#项目身份边界

身份所有者目的
HALO 帐户用户HALO访问开发人员仪表板
项目身份验证用户您的项目登录您的应用程序
上游提供商身份Google、Apple、GitHub、Microsoft验证项目用户
OAuth 应用客户端您的项目请求对已登录项目用户的范围访问

#电子邮件快速入门

  1. 1
    配置 URL

    设置站点 URL 以及项目可能使用的每个确切的重定向 URL。

  2. 2
    配置电子邮件

    添加Resend发送密钥、已验证的发件人地址以及三个必需的 HTML 模板。

  3. 3
    复制可发布密钥

    仪表板身份验证部分显示公共端点使用的项目密钥。

  4. 4
    创建用户会话

    Create the SDK client once, then sign up or sign in throughhalo.auth. The SDK persists the browser session and rotates refresh tokens automatically.

import { createClient } from "agihalo-node-sdk/auth";

const halo = createClient(
  "https://api.agihalo.com",
  HALO_PROJECT_PUBLISHABLE_KEY
);

const { data, error } = await halo.auth.signInWithPassword({
  email: "user@example.com",
  password: "use-a-strong-password",
});

if (error) throw error;

// The SDK automatically sends apikey + Bearer <access_token>.
const { data: currentUser } = await halo.auth.getUser();

#公共 API

GET/api/v1/auth/settings
POST/api/v1/auth/signup
POST/api/v1/auth/token?grant_type=password
POST/api/v1/auth/token?grant_type=refresh_token
GET/api/v1/auth/user
POST/api/v1/auth/logout
GET/api/v1/auth/.well-known/jwks.json

#选择下一个指南