это маршрут flask
Код: Выделить всё
@app.route("/tasks", methods=["GET"])
def get_tasks():
try:
id_token = request.headers.get("Authorization").split(" ")[1]
print(id_token)
# Verify the ID token while checking if the token is revoked by
# passing check_revoked=True.
decoded_token = auth.verify_id_token(id_token)
print(decoded_token)
# Token is valid and not revoked.
uid = decoded_token['uid']
except auth.RevokedIdTokenError as e:
# Token revoked, inform the user to reauthenticate or signOut().
return jsonify('RevokedIdTokenError')
except auth.UserDisabledError as e:
# Token belongs to a disabled user record.
return jsonify('UserDisabledError')
except auth.InvalidIdTokenError as e:
# Token is invalid
return jsonify('InvalidIdTokenError')
Код: Выделить всё
async function getTaskName() {
try {
const userToken = await getToken()
const response = await fetch('http://127.0.0.1:5000/tasks',{
method : 'GET',
headers: {
'Authorization': `Bearer ${userToken}` // Include token in Authorization header
}
});
const data = await response.json();
console.log(data)
//setTask(data)
} catch (error) {
console.error('Error fetching task:', error);
}
}
Я напечатал в консоли оба токена, и они оба идентичны.
Я напечатал ошибку из исключения. , см. ниже, однако часы моего компьютера установлены на автоматический режим и кажутся правильными
Код: Выделить всё
Token used too early, 1711964786 < 1711964789. Check that your computer's clock is set correctly.
Подробнее здесь: https://stackoverflow.com/questions/782 ... h-firebase