I’m considering deploying my Angular WebApp to the Azure Storage Static Website hosting. That methods of deploying my SPA is forcing me to use hash path for my routing.
Then my callback url from Auth0 must contains the hash too! But as I read on other threads here it seems impossible.
You can use the same root path of your application to be the callback URL. In the callback, you will be redirected with the authorization response in the fragment, something that looks like this:
At the start of your application logic you can use Auth0.js’ parseHash method to check for a valid authorization response and act accordingly:
auth0.parseHash(function(err, authResult) {
if (err) {
// this means an error came from a previous authorization request
return console.log(err);
} else if (authResult) {
// if you land here, it means that the fragment had a valid authorization response
//
// The contents of authResult depend on which authentication parameters were used.
// It can include the following:
// authResult.accessToken - access token for the API specified by `audience`
// authResult.expiresIn - string with the access token's expiration time in seconds
// authResult.idToken - ID token JWT containing user profile information
} else {
// no authentication result found in the fragment
// continue with the regular application startup flow
}
});
When typing the hash manually in the url bar (when the site is already loaded) it ignores it when the route does not exists. But loading the url with the hash from another page it works.
In the end, I’m finally using a RouteGuard to process it.