Получение токена из бэкэнда , когда я добавляю каждую вещь, эта ошибка показывает в моей консоли : My React Аутентификация не работает. (firebase реагирует) В моей консоли моя сетевая аутентификация не проходит. Это говорит мне, что не может опубликовать URL. Эта ошибка: var error = новая ошибка (сообщение);
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"
}
]
}
}
В моем проекте у меня было следующее:
axios.post('https://identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken?key=[API_KEY]', authData)
Это мой код:
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));
});
};
};