j-toker
j-toker copied to clipboard
Retrieve headers token
I'm working with the window fetch polyfill library and I'm trying retrieve data from the secure API.
How can I get the tokens that are use for every request in J-Toker and use them with the fetch lib.
Is there any kind of function to do something like that ?
import Auth from './auth-configuration';
// Getting the tokens
const tokens = Auth.getTokens();
// And use them is the request
fetch('/secure-api', tokens).then(...)
anyone ?
Looks like $.auth.retrieveData('authHeaders')
will retrieve the headers.
If you specify that as your headers, it will log you out. How do I put the headers in and still be able to keep my user logged in?
@dannymockaitis There's not a lot of detail in your problem description, but it sounds like the headers aren't getting into your request properly, causing a 401 to come back and log you out. Check out the headers in the request you're extracting the tokens for and compare them to the headers j-toker's using in its requests to verify correctness.