Paybin
获取你的 Paybin 凭证
要使用 Paybin 登录,你需要通过你的 Paybin 投资组合应用创建一个 OAuth 2.0 客户端。
- 登录到你的 Paybin 资源组合
- 导航到开发者设置或 OAuth 应用部分
- 点击“创建 OAuth 应用”或“新建应用”
- 填写必填字段:
- 应用名称:在授权过程中向用户显示的名称
- 重定向 URI:在本地开发时设置为
http://localhost:3000/api/auth/callback/paybin。在生产环境中,设置为https://yourdomain.com/api/auth/callback/paybin。如果更改了认证路由的基础路径,请相应更新重定向 URI。
- 创建后,将客户端ID和客户端密钥复制到你的环境变量中。请保持这些凭据的安全。
配置提供程序
要配置提供程序,你需要导入该提供程序并将其传递给身份验证实例的 socialProviders 选项。
import { betterAuth } from "better-auth"
export const auth = betterAuth({
socialProviders: {
paybin: {
clientId: process.env.PAYBIN_CLIENT_ID as string,
clientSecret: process.env.PAYBIN_CLIENT_SECRET as string,
},
},
})Sign In with Paybin
To sign in with Paybin, you can use the signIn.social function provided by the client, where the provider should be set to paybin.
import { createAuthClient } from "better-auth/client"
const authClient = createAuthClient()
const signIn = async () => {
const data = await authClient.signIn.social({
provider: "paybin"
})
}额外配置
【Additional Configuration】
范围
【Scopes】
默认情况下,Paybin 提供商请求以下权限范围:openid、email 和 profile。你可以根据应用的需求自定义这些权限范围。
【By default, Paybin provider requests the following scopes: openid, email, and profile. You can customize the scopes based on your application's needs.】
有关可用作用域及其说明的完整列表,请参阅 Paybin OIDC 作用域文档。
【For a complete list of available scopes and their descriptions, see the Paybin OIDC Scopes Documentation.】
export const auth = betterAuth({
socialProviders: {
paybin: {
clientId: process.env.PAYBIN_CLIENT_ID as string,
clientSecret: process.env.PAYBIN_CLIENT_SECRET as string,
scope: ["openid", "email", "profile", "transactions"],
},
},
})用户资料映射
【User Profile Mapping】
Paybin 根据 OpenID Connect 标准在 ID 令牌中返回用户信息。提供者会自动提取:
id来自sub声明name来自name、preferred_username或email(按优先顺序)email来自email声明image来自picture声明emailVerified来自email_verified声明
【Paybin returns user information in the ID token following OpenID Connect standards. The provider automatically extracts:
idfromsubclaimnamefromname,preferred_username, oremail(in order of preference)emailfromemailclaimimagefrompictureclaimemailVerifiedfromemail_verifiedclaim】