From 8eeedb444fd58bae9c403f39b216d9f2634d9c5f Mon Sep 17 00:00:00 2001 From: imeepos Date: Mon, 8 Sep 2025 14:19:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DDouyinAuthClient?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E7=AD=BE=E5=90=8D=E5=92=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=AF=A6=E7=BB=86=E8=B0=83=E8=AF=95=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将getAccessToken方法改为async异步方法 - 在构造函数中添加配置和Client创建的调试信息 - 在getAccessToken方法中添加完整的调用流程调试 - 添加try-catch错误处理和详细的错误日志 - 隐藏敏感的clientSecret信息在日志中 --- .../adapters/DouYinClient.ts | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/content-moderation/adapters/DouYinClient.ts b/src/content-moderation/adapters/DouYinClient.ts index 07ec628..fbac280 100644 --- a/src/content-moderation/adapters/DouYinClient.ts +++ b/src/content-moderation/adapters/DouYinClient.ts @@ -18,13 +18,29 @@ body: export class DouyinAuthClient { private readonly client: Client; constructor(private config: ConfigService) { + console.log('DouyinAuthClient constructor - creating client with:', { + clientKey: this.config.get('BYTEDANCE_APP_ID') || '', + clientSecret: this.config.get('BYTEDANCE_APP_SECRET') ? '***' : 'empty' + }); this.client = new Client({ clientKey: this.config.get('BYTEDANCE_APP_ID') || '', clientSecret: this.config.get('BYTEDANCE_APP_SECRET') || '', - }) + }); + console.log('DouyinAuthClient constructor - client created:', !!this.client); + console.log('DouyinAuthClient constructor - client.getAccessToken type:', typeof this.client.getAccessToken); } - getAccessToken() { - return this.client.getAccessToken() + async getAccessToken() { + console.log('DouyinAuthClient.getAccessToken called'); + console.log('client:', !!this.client); + console.log('client.getAccessToken type:', typeof this.client.getAccessToken); + try { + const result = await this.client.getAccessToken(); + console.log('getAccessToken result:', result); + return result; + } catch (error) { + console.error('getAccessToken error:', error); + throw error; + } } } \ No newline at end of file