mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-14 12:02:27 +08:00
Merge pull request #5158 from neboyang/feat/claude-oauth-authorize-url
fix(oauth): use claude.com/cai authorize endpoint
This commit is contained in:
@@ -19,7 +19,7 @@ const (
|
||||
ClientID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e"
|
||||
|
||||
// OAuth endpoints
|
||||
AuthorizeURL = "https://claude.ai/oauth/authorize"
|
||||
AuthorizeURL = "https://claude.com/cai/oauth/authorize"
|
||||
TokenURL = "https://platform.claude.com/v1/oauth/token"
|
||||
RedirectURI = "https://platform.claude.com/oauth/code/callback"
|
||||
|
||||
|
||||
@@ -1,11 +1,36 @@
|
||||
package oauth
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestAuthorizeURLMatchesClaudeCodeCLI(t *testing.T) {
|
||||
const want = "https://claude.com/cai/oauth/authorize"
|
||||
if AuthorizeURL != want {
|
||||
t.Fatalf("AuthorizeURL = %q, want %q", AuthorizeURL, want)
|
||||
}
|
||||
|
||||
authURL := BuildAuthorizationURL("state-value", "challenge-value", ScopeOAuth)
|
||||
if !strings.HasPrefix(authURL, want+"?") {
|
||||
t.Fatalf("BuildAuthorizationURL() = %q, want prefix %q", authURL, want+"?")
|
||||
}
|
||||
for _, part := range []string{
|
||||
"code=true",
|
||||
"client_id=" + ClientID,
|
||||
"response_type=code",
|
||||
"code_challenge=challenge-value",
|
||||
"code_challenge_method=S256",
|
||||
"state=state-value",
|
||||
} {
|
||||
if !strings.Contains(authURL, part) {
|
||||
t.Fatalf("BuildAuthorizationURL() missing %q\nURL: %s", part, authURL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionStore_Stop_Idempotent(t *testing.T) {
|
||||
store := NewSessionStore()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user