有自己服务器的网站
你的服务器保存一个密钥,并用一次性授权码换取令牌,所以这是最简单也最安全的登录方式。
在你自己的服务器上,这不需要开启任何设置。
逐步了解它如何运作
- 1用户在你的网站上点击“登录”。
- 2你的服务器把浏览器转到 FoxAuth 的登录页面。
- 3用户输入密码,或者使用 Google 登录。只有 FoxAuth 能看到密码。
- 4FoxAuth 把用户送回你的回调地址,并附上一个一次性授权码。
- 5你的服务器出示自己的密钥,用授权码换取令牌。浏览器始终看不到这一步。
- 6你的服务器建立会话,用户登录成功。
注意事项
- 只有 localhost 可以使用普通 http。其他地址都需要 https。
- 把密钥放在服务器的环境变量中,绝不要写进代码。
给你的智能体的提示词
把它粘贴到 Claude、Cursor 或其他编程智能体中。它涵盖你的代码和控制台中的设置。提示词是英文的。
Add sign-in through FoxAuth to my web app with a server (work out the stack from the code). Flow: Authorization Code + PKCE, a confidential application (client_secret_basic), refresh tokens. Callback: http://localhost:3000/callback. After sign-out: http://localhost:3000. The server’s issuer is <your project's issuer, on its Overview> and its discovery document is <issuer>/.well-known/openid-configuration. If the FoxAuth administrative MCP is connected, use client_create with applicationType web, grantTypes authorization_code and refresh_token, tokenEndpointAuthMethod client_secret_basic. Otherwise ask me to press the button for this in the console at https://auth.foxauth.dev/admin. Keep the secret only on the server, in an environment variable.
底层协议: OpenID Connect · Authorization Code + PKCE · client_secret_basic · 刷新令牌