Is there a way to log in using a token?
So here is a short example of logging in with a “Username-Password-Authentication” “realm”. Assume that the authClient setup is all set up well.
const AUTH_REALM = "Username-Password-Authentication";
authClient.auth0.login(
{
realm: AUTH_REALM,
email,
password
},
(err) => {
resolve();
if (err) {
console.log(err);
reject(err);
}
}
);
I’d like a way to use a token retrieved from Auth0 to do the same function so it would look something like:
const TOKEN_REALM = "Token-Authentication";
authClient.auth0.login(
{
realm: TOKEN_REALM ,
token
},
(err) => {
resolve();
if (err) {
console.log(err);
reject(err);
}
}
);
For context, I’d like to use this so that after I verify a user, I also log them in using the token that is provided. I, of course, don’t have access to the password.
Hello!
I’ve got your problem. We’ll give you a response as soon as possible.
Lada Kokotova | Technical Support Engineer
Where do you get this token from?
The token is a jwt signed token with this information:
const token = jwt.sign(
{
user: {
auth0UserId: user.auth0UserId,
id: user.id,
email: user.email
}
},
"<JWTsecret>"
)
So I don’t necessarily need to authenticate with just the token itself, but I want a way to perhaps parse data from it, have a token with specific information inside that would allow me to log a user in after activating
I still cannot understand for what purpose it is needed. Can you describe your flow, please?
Anyway, you can use on client-side something like this:
const authClient = Auth.createClient(...)
// ....
const setToken = (token) => {
authClient.setState({ token });
};
at this case there will be no interaction with a third API
for authorized verification you can use authClient.checkIsAuthorized