Atlassian

获取你的凭据

  1. 登录你的 Atlassian 账户并访问 Atlassian 开发者控制台
  2. 点击“创建新应用”
  3. 填写应用详细信息
  4. 配置重定向 URI(例如,https://yourdomain.com/api/auth/callback/atlassian
  5. 记录你的客户端 ID 和客户端密钥
  • 默认的权限范围是 read:jira-useroffline_access。有关其他权限范围,请参阅 Atlassian OAuth 文档

确保将重定向 URI 设置为与你的应用回调 URL 相匹配。如果你更改了认证路由的基本路径,应相应地更新重定向 URI。

配置提供程序

要配置提供程序,你需要导入该提供程序并将其传递给身份验证实例的 socialProviders 选项。

auth.ts
import { betterAuth } from "better-auth"

export const auth = betterAuth({
    socialProviders: {
        atlassian: { 
            clientId: process.env.ATLASSIAN_CLIENT_ID as string, 
            clientSecret: process.env.ATLASSIAN_CLIENT_SECRET as string, 
        }, 
    },
})

Sign In with Atlassian

To sign in with Atlassian, you can use the signIn.social function provided by the client. The signIn function takes an object with the following properties:

  • provider: The provider to use. It should be set to atlassian.
auth-client.ts
import { createAuthClient } from "better-auth/client"
const authClient =  createAuthClient()

const signIn = async () => {
    const data = await authClient.signIn.social({
        provider: "atlassian"
    })
}

For more information about Atlassian's OAuth scopes and API capabilities, refer to the official Atlassian OAuth 2.0 (3LO) apps documentation.

On this page