-1
I am trying to make a request to pick up session in an API, it is with the Oauth2 system, where I have to send a form-urlencoded with some data and it returns me a token. But I can not do the request, Ta giving error 400.
Follow my saga:
import { takeLatest, call, put, all } from 'redux-saga/effects';
import history from '../../../services/history';
import api from '../../../services/api';
import { signInSuccess } from './actions';
export function* signIn({ payload }) {
const { email, password, grant_type } = payload;
const client_id = 'aVgjhEBcnN-ytRrewsWJrSpoKnh';
const client_secret = 'q4fYtRGIkmLJKtx9Y5MaUYFPPdasd2QD4hTI4Gds45tgfSAdlkj';
const token = 'Basic ' + btoa(`${client_id}:${client_secret}`);
const headers = {
'content-type': 'application/x-www-form-urlencoded;charset=utf-8',
token,
};
const response = yield call(
api.post,
'auth/token',
{
email: email,
password: password,
grant_type: grant_type,
},
{ headers }
);
console.log(response);
history.push('/dashboard');
}
export default all([takeLatest('@auth/SIGN_IN_REQUEST', signIn)]);
Follow the Archive of the Request:
Now follow the print of the error you made when making the request on the login page:
My question is, what am I doing wrong that is returning me error 400?