Получить токен Spring OAUTH в форму используя Node.js
Сейчас мой OAuth сервер на POST запрос
http://localhost:9191/oauth/token
с такими данными
возвращает рабочий токен в теле json. где Basic d2ViOndlYnBhc3M= это закодированный юзер
Я выдаюсь получить этот же токен в форму на node.js используя такой метод
app.post('/login', function (req, res) {
let username = req.body.inputEmail;
let password = req.body.inputPassword;
let formData = new FormData();
formData.append('grant_type','password');
formData.append('username',username);
formData.append('password',password);
fetch('http://localhost:9191/oauth/token', {
method: 'POST',
body: formData,
headers: {
'Authorization': 'Basic d2ViOndlYnBhc3M=',
'Content-Type': 'application/x-www-form-urlencoded'
}
}).then(function (data) {
console.log(data);
});
console.log(username);
console.log(password);
res.render('sign-in');
});
ничего нужного не приходит. вот такой лог в консоли
Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: {
body: PassThrough {
_readableState: [ReadableState],
readable: true,
_events: [Object: null prototype],
_eventsCount: 5,
_maxListeners: undefined,
_writableState: [WritableState],
writable: true,
allowHalfOpen: true,
_transformState: [Object],
[Symbol(kCapture)]: false
},
disturbed: false,
error: null
},
[Symbol(Response internals)]: {
url: 'http://localhost:9191/oauth/token',
status: 400,
statusText: 'Bad Request',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
}
}
krish
krishpass
Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: {
body: PassThrough {
_readableState: [ReadableState],
readable: true,
_events: [Object: null prototype],
_eventsCount: 5,
_maxListeners: undefined,
_writableState: [WritableState],
writable: true,
allowHalfOpen: true,
_transformState: [Object],
[Symbol(kCapture)]: false
},
disturbed: false,
error: null
},
[Symbol(Response internals)]: {
url: 'http://localhost:9191/oauth/token',
status: 400,
statusText: 'Bad Request',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
}
}
