Hi,
I implemented the authentication in the front end as such :
userLogin: function() {
let deferred = new Ext.Deferred();
//Create auth0 client
//TODO ADA : move domain and client_id to auth_config.json
createAuth0Client({
domain: "domain",
client_id: "clientId",
audience: "audience",
useRefreshTokens: true
}).then(function(auth0) {
try {
auth0.isAuthenticated().then(async function (authenticated) {
if (!authenticated) {
const query = window.location.search;
const shouldParseResult = query.includes("code=") && query.includes("state=");
if (shouldParseResult) {
console.log("> Parsing redirect");
try {
const result = await auth0.handleRedirectCallback();
console.log("Logged in!");
deferred.resolve();
} catch (err) {
console.log("Error parsing redirect:", err);
deferred.reject();
}
window.history.replaceState({}, document.title, "/");
} else {
auth0.loginWithRedirect({ redirect_uri: window.location.origin });
deferred.resolve();
}
} else {
auth0.getTokenSilently().then(function (token) {
debugger;
Ext.Ajax.setDefaultHeaders({ 'Authorization': 'Bearer ' + token });
deferred.resolve();
});
}
})
} catch (err) {
console.log("Log in failed", err);
deferred.reject();
}
});
return deferred.promise;
}
And I configured my API using this doc :
var domain = $"domain";
var apiIdentifier = "identifier";
var keyResolver = new OpenIdConnectSigningKeyResolver(domain);
app.UseJwtBearerAuthentication(
new JwtBearerAuthenticationOptions
{
AuthenticationMode = AuthenticationMode.Active,
TokenValidationParameters = new TokenValidationParameters()
{
ValidAudience = apiIdentifier,
ValidIssuer = domain,
IssuerSigningKeyResolver = (token, securityToken, kid, parameters) => keyResolver.GetSigningKey(kid)
}
});
Now I need to Identify my user in the back end to load his preferences etc.
How can I do this?
I tried to decode the token (https://jwt.io/) but it seems to be empty or malformed.
Thanks