Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
a1292fac
Commit
a1292fac
authored
Jan 23, 2026
by
shaw
Browse files
feat(oauth): 支持Anthropic的Team账号使用sk授权
parent
7f98be4f
Changes
1
Hide whitespace changes
Inline
Side-by-side
backend/internal/repository/claude_oauth_service.go
View file @
a1292fac
...
@@ -35,7 +35,9 @@ func (s *claudeOAuthService) GetOrganizationUUID(ctx context.Context, sessionKey
...
@@ -35,7 +35,9 @@ func (s *claudeOAuthService) GetOrganizationUUID(ctx context.Context, sessionKey
client
:=
s
.
clientFactory
(
proxyURL
)
client
:=
s
.
clientFactory
(
proxyURL
)
var
orgs
[]
struct
{
var
orgs
[]
struct
{
UUID
string
`json:"uuid"`
UUID
string
`json:"uuid"`
Name
string
`json:"name"`
RavenType
*
string
`json:"raven_type"`
// nil for personal, "team" for team organization
}
}
targetURL
:=
s
.
baseURL
+
"/api/organizations"
targetURL
:=
s
.
baseURL
+
"/api/organizations"
...
@@ -65,7 +67,23 @@ func (s *claudeOAuthService) GetOrganizationUUID(ctx context.Context, sessionKey
...
@@ -65,7 +67,23 @@ func (s *claudeOAuthService) GetOrganizationUUID(ctx context.Context, sessionKey
return
""
,
fmt
.
Errorf
(
"no organizations found"
)
return
""
,
fmt
.
Errorf
(
"no organizations found"
)
}
}
log
.
Printf
(
"[OAuth] Step 1 SUCCESS - Got org UUID: %s"
,
orgs
[
0
]
.
UUID
)
// 如果只有一个组织,直接使用
if
len
(
orgs
)
==
1
{
log
.
Printf
(
"[OAuth] Step 1 SUCCESS - Single org found, UUID: %s, Name: %s"
,
orgs
[
0
]
.
UUID
,
orgs
[
0
]
.
Name
)
return
orgs
[
0
]
.
UUID
,
nil
}
// 如果有多个组织,优先选择 raven_type 为 "team" 的组织
for
_
,
org
:=
range
orgs
{
if
org
.
RavenType
!=
nil
&&
*
org
.
RavenType
==
"team"
{
log
.
Printf
(
"[OAuth] Step 1 SUCCESS - Selected team org, UUID: %s, Name: %s, RavenType: %s"
,
org
.
UUID
,
org
.
Name
,
*
org
.
RavenType
)
return
org
.
UUID
,
nil
}
}
// 如果没有 team 类型的组织,使用第一个
log
.
Printf
(
"[OAuth] Step 1 SUCCESS - No team org found, using first org, UUID: %s, Name: %s"
,
orgs
[
0
]
.
UUID
,
orgs
[
0
]
.
Name
)
return
orgs
[
0
]
.
UUID
,
nil
return
orgs
[
0
]
.
UUID
,
nil
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment