From 7b9e7d0a99930a4e88a40478607556e47bcb3269 Mon Sep 17 00:00:00 2001 From: "xingzhe.ru" Date: Wed, 2 Jul 2025 09:27:12 +0000 Subject: [PATCH] update server/routers/back-new/features/image/image.controller.js --- .../back-new/features/image/image.controller.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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',