fix: handle authorization code format in ExchangeCode function and update placeholder in EditChannelModal
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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) => {
|
||||
<Input
|
||||
value={authorizationCode}
|
||||
onChange={setAuthorizationCode}
|
||||
placeholder={t('请输入授权码或回调URL')}
|
||||
placeholder={t('请输入授权码')}
|
||||
showClear
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user