update server/routers/back-new/features/image/image.controller.js
This commit is contained in:
@@ -1,14 +1,25 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const makeLinks = require('../../shared/hateoas');
|
const makeLinks = require('../../shared/hateoas');
|
||||||
const { v4: uuidv4 } = require('uuid');
|
const { v4: uuidv4 } = require('uuid');
|
||||||
|
const qs = require('qs');
|
||||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
||||||
|
|
||||||
// 获取access_token
|
// 获取access_token
|
||||||
async function fetchAccessToken(apiKey) {
|
async function fetchAccessToken(apiKey) {
|
||||||
try {
|
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(
|
const tokenResp = await axios.post(
|
||||||
'https://ngw.devices.sberbank.ru:9443/api/v2/oauth',
|
'https://ngw.devices.sberbank.ru:9443/api/v2/oauth',
|
||||||
{ scope: 'GIGACHAT_API_PERS' },
|
qs.stringify({ scope: 'GIGACHAT_API_PERS' }),
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
|||||||
Reference in New Issue
Block a user