feat: add Setup Token OAuth flow for simplified Claude account setup

Introduces a streamlined Setup Token authentication method that reduces the required OAuth scopes from 'org:create_api_key user:profile user:inference' to just 'user:inference', simplifying the account setup process for users who only need inference capabilities.

Key changes:
- Add Setup Token authorization endpoints in admin routes
- Implement Setup Token OAuth flow with PKCE support in oauthHelper
- Update AccountForm to support Setup Token as the default auth method
- Add automatic authorization code extraction from callback URLs
- Maintain full proxy configuration support for Setup Token flow
- Preserve existing OAuth flow for advanced users requiring API key creation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
千羽
2025-08-07 22:48:48 +09:00
parent 5f01d87600
commit 35e16038a5
4 changed files with 620 additions and 8 deletions

View File

@@ -398,6 +398,42 @@ export const useAccountsStore = defineStore('accounts', () => {
}
}
// 生成Claude Setup Token URL
const generateClaudeSetupTokenUrl = async (proxyConfig) => {
try {
const response = await apiClient.post(
'/admin/claude-accounts/generate-setup-token-url',
proxyConfig
)
if (response.success) {
return response.data // 返回整个对象包含authUrl和sessionId
} else {
throw new Error(response.message || '生成Setup Token URL失败')
}
} catch (err) {
error.value = err.message
throw err
}
}
// 交换Claude Setup Token Code
const exchangeClaudeSetupTokenCode = async (data) => {
try {
const response = await apiClient.post(
'/admin/claude-accounts/exchange-setup-token-code',
data
)
if (response.success) {
return response.data
} else {
throw new Error(response.message || '交换Setup Token授权码失败')
}
} catch (err) {
error.value = err.message
throw err
}
}
// 生成Gemini OAuth URL
const generateGeminiAuthUrl = async (proxyConfig) => {
try {
@@ -480,6 +516,8 @@ export const useAccountsStore = defineStore('accounts', () => {
refreshClaudeToken,
generateClaudeAuthUrl,
exchangeClaudeCode,
generateClaudeSetupTokenUrl,
exchangeClaudeSetupTokenCode,
generateGeminiAuthUrl,
exchangeGeminiCode,
sortAccounts,