I use a JWT-token for authentication of users in my ASP.NET Core Web App.
The process of authentication has following steps:
- Client send an ajax request to the server url with params login/password to get access token
- Server get request and send a response with access token and token type
Client get server response and save token in a session storage to use token for requests later
When client has a token he should add token type and token to header of every request like the following sample (jQuery.ajax() headers section):
headers: { 'Authorization' : tokenType + ' ' + token }
Client redirects user from login page to main page. In JavaScript I can make it with the following code:
Code:
window.location.replace('[URL_TO_MAIN_PAGE_HERE]');
or
window.location.href = [URL_TO_MAIN_PAGE_HERE];
However I has a problem that I can't set a header for the request above.
How can I redirect user to main page after login if I use access token for authentication?
Additional info:
App is not SPA.