Getting a token from the backend ,when i add every thing this error is showing in my console : My React Authentication is not working. (firebase react) In my console my network authentication is failing. Its telling me cannot post url. This error : var error = new Error(message);
Error: "Request failed with status code 400"
createError createError.js:16
settle settle.js:17
handleLoad xhr.js:61
In Network Response this error is showing :
{
"error": {
"code": 400,
"message": "MISSING_CUSTOM_TOKEN",
"errors": [
{
"message": "MISSING_CUSTOM_TOKEN",
"domain": "global",
"reason": "invalid"
}
]
}
}
In my project I had at this :
axios.post('https://identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken?key=[API_KEY]', authData)
This is my code :
This is my code :
auth.js :
import axios from 'axios';
import * as actionTypes from './actionTypes';
export const authStart = () => {
return {
type: actionTypes.AUTH_START
};
};
export const authSuccess = (authData) => {
return {
type: actionTypes.AUTH_SUCCESS,
authData: authData
};
};
export const authFail = (error) => {
return {
type: actionTypes.AUTH_FAIL,
error: error
};
};
export const auth = (email, password) => {
return dispatch => {
dispatch(authStart());
const authData = {
email: email,
password: password,
returnSecureToken: true
};
axios.post('https://identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken?key=[API_KEY]', authData)
.then(response => {
console.log(response);
dispatch(authSuccess(response.data));
})
.catch(err => {
console.log(err);
dispatch(authFail(err));
});
};
};