Returns a fetch-compatible function that automatically attaches the
authenticated user's access token as an Authorization: Bearer header.
The returned function has the same signature as the global fetch. Use it
for any request to your own backend that expects a Hiyve access token.
When no user is signed in, the header is omitted and the request is sent
unauthenticated.
Token freshness is handled for you: a token at or past expiry (for
example after the tab slept through a long practice or reading session)
is refreshed before the request is sent, and a request the server refuses
as unauthorized is retried once with a freshly minted token. The retry
applies to requests made with a URL; a Request object whose body has
been consumed cannot be resent, so those return the original response.
The returned function has a stable reference for the lifetime of the
identity session, so it is safe to pass to useEffect / useCallback
dependency arrays.
Returns a
fetch-compatible function that automatically attaches the authenticated user's access token as anAuthorization: Bearerheader.The returned function has the same signature as the global
fetch. Use it for any request to your own backend that expects a Hiyve access token. When no user is signed in, the header is omitted and the request is sent unauthenticated.Token freshness is handled for you: a token at or past expiry (for example after the tab slept through a long practice or reading session) is refreshed before the request is sent, and a request the server refuses as unauthorized is retried once with a freshly minted token. The retry applies to requests made with a URL; a
Requestobject whose body has been consumed cannot be resent, so those return the original response.The returned function has a stable reference for the lifetime of the identity session, so it is safe to pass to
useEffect/useCallbackdependency arrays.