From aa5c85ca3f2a5e05643c0a79d0b77cf970adf584 Mon Sep 17 00:00:00 2001 From: MurphyYi Date: Fri, 13 Nov 2026 18:59:30 +0800 Subject: [PATCH] =?UTF-8?q?refactor!:=20=E5=88=A0=20NewClientFromOAuthToke?= =?UTF-8?q?n=20=E5=85=BC=E5=AE=B9=E6=9E=84=E9=80=A0=E2=80=94=E2=80=94OAuth?= =?UTF-8?q?Client.NewClient=20=E5=8D=95=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deprecated 包级构造 NewClientFromOAuthToken 固定公网 base URL,私有部署 丢 URL 的坑已由 OAuthClient.NewClient(沿用 OAuthClient 的 base URL)修复; 旧构造零消费(仅示例注释提及),删除收口。示例注释同步改指 oauth.NewClient。 **BREAKING**:仓外若用 gitcode.NewClientFromOAuthToken(token),改 oauth.NewClient(token)(私有部署必须用后者,否则客户端指向公网)。 --- examples/main.go | 4 ++-- oauth.go | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/examples/main.go b/examples/main.go index 1da2f34..10b4402 100644 --- a/examples/main.go +++ b/examples/main.go @@ -159,8 +159,8 @@ func main() { // token, err := oauth.ExchangeToken(ctx, code) // if err != nil { log.Fatal(err) } - // 3. 用 token 创建客户端 - // client := gitcode.NewClientFromOAuthToken(token) + // 3. 用 token 创建客户端(沿用 OAuthClient 的 base URL,私有部署正确) + // client := oauth.NewClient(token) // 4. 刷新 token // token, err = oauth.RefreshToken(ctx, token.RefreshToken) diff --git a/oauth.go b/oauth.go index f5f7f02..734340e 100644 --- a/oauth.go +++ b/oauth.go @@ -122,9 +122,3 @@ func (o *OAuthClient) doTokenRequest(ctx context.Context, data url.Values) (*OAu func (o *OAuthClient) NewClient(token *OAuthToken) *Client { return NewClientWithBaseURL(o.baseURL+"/api/v5", token.AccessToken) } - -// Deprecated: NewClientFromOAuthToken creates a client from an OAuth token using the default public base URL. -// For private deployments, use OAuthClient.NewClient() instead, which preserves the base URL. -func NewClientFromOAuthToken(token *OAuthToken) *Client { - return NewClient(token.AccessToken) -}