That the requests to server side API calls are injected with a bearer token as a header. This authenticates the request if adminAuth is enabled in the settings.js file.
If fetch is used within the registered endpoint then this token is not injected and the request is unauthorized a 401 error is thrown.
Is there a way of accessing this token and adding it as a header to the fetch request?
, however it has an expires_in property. Does this property value get updated from time to time?
I am just wondering if there is an already defined method within Node RED for extracting the token and verifying its validity. i.e. is still valid/not expired.
How and where the token is stored inside the editor is an internal implementation detail that could well change in the future as we reconsider some of the use of localStorage. So I would carefully consider whether it's worth the maintenance overhead just to get to use fetch rather than the included client.