Compare commits
2 Commits
dfa2d5eaae
...
8eeedb444f
| Author | SHA1 | Date |
|---|---|---|
|
|
8eeedb444f | |
|
|
d3562b4d36 |
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -36,6 +36,13 @@ export class DouyinContentAdapter extends BaseContentAdapter {
|
|||
) {
|
||||
super(httpService, configService, auditLogRepository);
|
||||
|
||||
// 调试:检查 douyinAuthClient 是否正确注入
|
||||
console.log('DouyinContentAdapter constructor - douyinAuthClient:', this.douyinAuthClient);
|
||||
console.log('douyinAuthClient type:', typeof this.douyinAuthClient);
|
||||
if (this.douyinAuthClient) {
|
||||
console.log('douyinAuthClient.getAccessToken type:', typeof this.douyinAuthClient.getAccessToken);
|
||||
}
|
||||
|
||||
// 抖音开放平台配置:clientKey/clientSecret 实际使用的是 APP_ID/APP_SECRET
|
||||
this.douyinConfig = {
|
||||
clientKey: this.configService.get('BYTEDANCE_APP_ID') || '',
|
||||
|
|
@ -157,6 +164,17 @@ export class DouyinContentAdapter extends BaseContentAdapter {
|
|||
* 获取访问令牌
|
||||
*/
|
||||
private async getAccessToken(): Promise<string> {
|
||||
console.log('getAccessToken called - douyinAuthClient:', this.douyinAuthClient);
|
||||
console.log('douyinAuthClient type:', typeof this.douyinAuthClient);
|
||||
|
||||
if (!this.douyinAuthClient) {
|
||||
throw new Error('DouyinAuthClient 未正确注入');
|
||||
}
|
||||
|
||||
if (typeof this.douyinAuthClient.getAccessToken !== 'function') {
|
||||
throw new Error(`DouyinAuthClient.getAccessToken 不是函数,类型: ${typeof this.douyinAuthClient.getAccessToken}`);
|
||||
}
|
||||
|
||||
return this.douyinAuthClient.getAccessToken().then(res => res.accessToken)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,6 @@ import { ContentAuditGuard } from './guards/content-audit.guard';
|
|||
ContentAuditGuard,
|
||||
],
|
||||
controllers: [ContentModerationController],
|
||||
exports: [UnifiedContentService, ContentAdapterFactory, ContentAuditGuard],
|
||||
exports: [UnifiedContentService, ContentAdapterFactory, ContentAuditGuard, DouyinAuthClient],
|
||||
})
|
||||
export class ContentModerationModule {}
|
||||
|
|
|
|||
Loading…
Reference in New Issue