feature/worker #111
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user