Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

fix(agent-cli): correct Claude OAuth client and endpoints

thinhlpga2c7bc3ff831
diff --git a/src-tauri/src/core/cli/auth/account.rs b/src-tauri/src/core/cli/auth/account.rs
index 1ee394e75..a66ae0cb4 100644
--- a/src-tauri/src/core/cli/auth/account.rs
+++ b/src-tauri/src/core/cli/auth/account.rs
@@ -60,10 +60,10 @@ pub fn begin(provider: AccountProvider) -> Result<AccountLogin, String> {
"openid profile email offline_access",
),
AccountProvider::Claude => (
- "1d1c250a-e61b-44d9-88ed-5944d1962f5e",
+ "9d1c250a-e61b-44d9-88ed-5944d1962f5e",
"https://claude.ai/oauth/authorize",
- "https://platform.claude.com/v1/oauth/token",
- "http://localhost:53692/callback",
+ "https://api.anthropic.com/v1/oauth/token",
+ "http://localhost:54545/callback",
"org:create_api_key user:profile user:inference user:sessions:claude_code user:mcp_servers user:file_upload",
),
};
@@ -335,8 +335,8 @@ pub async fn refresh(provider: AccountProvider, token: &OAuthToken) -> Result<OA
"https://auth.openai.com/oauth/token",
),
AccountProvider::Claude => (
- "1d1c250a-e61b-44d9-88ed-5944d1962f5e",
- "https://platform.claude.com/v1/oauth/token",
+ "9d1c250a-e61b-44d9-88ed-5944d1962f5e",
+ "https://api.anthropic.com/v1/oauth/token",
),
};
let response = reqwest::Client::new()
@@ -687,10 +687,25 @@ mod tests {
.1,
"S256"
);
- assert_eq!(login.redirect_uri, "http://localhost:53692/callback");
+ assert_eq!(login.redirect_uri, "http://localhost:54545/callback");
assert!(!login.state.is_empty());
assert!(!login.verifier.is_empty());
}
+ #[test]
+ fn claude_browser_login_uses_registered_client_id() {
+ let login = begin(AccountProvider::Claude).unwrap();
+ let url = url::Url::parse(&login.authorization_url).unwrap();
+
+ assert_eq!(
+ url.query_pairs()
+ .find(|(key, _)| key == "client_id")
+ .unwrap()
+ .1,
+ "9d1c250a-e61b-44d9-88ed-5944d1962f5e"
+ );
+ assert_eq!(login.client_id, "9d1c250a-e61b-44d9-88ed-5944d1962f5e");
+ assert_eq!(login.token_endpoint, "https://api.anthropic.com/v1/oauth/token");
+ }
#[test]
fn callback_requires_the_matching_state() {