diff --git a/server/routers/back-new/features/image/image.controller.js b/server/routers/back-new/features/image/image.controller.js index 2f8dd6a..b3f1c6b 100644 --- a/server/routers/back-new/features/image/image.controller.js +++ b/server/routers/back-new/features/image/image.controller.js @@ -1,14 +1,25 @@ const axios = require('axios'); const makeLinks = require('../../shared/hateoas'); const { v4: uuidv4 } = require('uuid'); +const qs = require('qs'); process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; // 获取access_token async function fetchAccessToken(apiKey) { try { + console.log('请求token参数:', { + url: 'https://ngw.devices.sberbank.ru:9443/api/v2/oauth', + data: qs.stringify({ scope: 'GIGACHAT_API_PERS' }), + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + 'Accept': 'application/json', + 'Authorization': `Basic ${apiKey}`, + 'RqUID': uuidv4() + } + }); const tokenResp = await axios.post( 'https://ngw.devices.sberbank.ru:9443/api/v2/oauth', - { scope: 'GIGACHAT_API_PERS' }, + qs.stringify({ scope: 'GIGACHAT_API_PERS' }), { headers: { 'Content-Type': 'application/x-www-form-urlencoded',