From 6f56696af2591c594bdd6424c97f0a26adb8dd5e Mon Sep 17 00:00:00 2001 From: Seefs Date: Thu, 31 Jul 2025 21:27:24 +0800 Subject: [PATCH] fix: handle authorization code format in ExchangeCode function and update placeholder in EditChannelModal --- service/claude_oauth.go | 11 +++++++++-- .../table/channels/modals/EditChannelModal.jsx | 3 +-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/service/claude_oauth.go b/service/claude_oauth.go index 136269ae..b0e1f84d 100644 --- a/service/claude_oauth.go +++ b/service/claude_oauth.go @@ -60,7 +60,7 @@ type OAuth2Credentials struct { // GetClaudeOAuthConfig returns the Claude OAuth2 configuration func GetClaudeOAuthConfig() *oauth2.Config { authorizeURL, tokenURL, clientID, redirectURI, scopes := getOAuthValues() - + return &oauth2.Config{ ClientID: clientID, RedirectURL: redirectURI, @@ -103,6 +103,13 @@ func GenerateOAuthParams() (*OAuth2Credentials, error) { func ExchangeCode(authorizationCode, codeVerifier, state string, client *http.Client) (*oauth2.Token, error) { config := getOAuthConfig() + if strings.Contains(authorizationCode, "#") { + parts := strings.Split(authorizationCode, "#") + if len(parts) > 0 { + authorizationCode = parts[0] + } + } + ctx := context.Background() if client != nil { ctx = context.WithValue(ctx, oauth2.HTTPClient, client) @@ -141,7 +148,7 @@ func GetClaudeHTTPClient() *http.Client { // RefreshClaudeToken refreshes a Claude OAuth token using the refresh token func RefreshClaudeToken(accessToken, refreshToken string) (*oauth2.Token, error) { config := GetClaudeOAuthConfig() - + // Create token from current values currentToken := &oauth2.Token{ AccessToken: accessToken, diff --git a/web/src/components/table/channels/modals/EditChannelModal.jsx b/web/src/components/table/channels/modals/EditChannelModal.jsx index 8eb3c5a6..cb09b3c9 100644 --- a/web/src/components/table/channels/modals/EditChannelModal.jsx +++ b/web/src/components/table/channels/modals/EditChannelModal.jsx @@ -57,7 +57,6 @@ import { IconSetting, } from '@douyinfe/semi-icons'; import React, { useEffect, useMemo, useRef, useState } from 'react'; -import { copy, getChannelIcon, getChannelModels, getModelCategories, modelSelectFilter } from '../../../../helpers'; import { useIsMobile } from '../../../../hooks/common/useIsMobile.js'; import { useTranslation } from 'react-i18next'; @@ -1853,7 +1852,7 @@ const EditChannelModal = (props) => {