Closed raj-saroj-vst-au4 closed 3 months ago
This is the purpose of #12
https://github.com/itpropro/nuxt-oidc-auth/pull/12 was merged but its not reflected in npm, is it even published ?
after trying your commit, it works but its not able to refresh token on my version of keycloak ! urlsearchparams() works for both accesstoken and refresh token, despite default tokenaccesstype as form.
It's not published yet, because the current implementation breaks some other providers.
Currently. the content-type is already application/x-www-form-urlencoded
when using the form format based on the FormData
, which is the standard defined by the fetch spec.
I will have to find a fix first to handle these special KeyCloak use cases without breaking the other providers, as explicitly defining content-type headers is not recommended and should be avoided if possible, which is why it breaks other providers.
EDIT: It is currently no possible to use form-data
due to a bug in ofetch and we have to rely on the native inference of fetch (https://github.com/unjs/ofetch/issues/37#issuecomment-1669678640)
So for now, application/x-www-form-urlencoded
and application/json
will stay the only supported content-types, I will expriment with ofetch to see if I can get it to work with multipart/form-data
as well, but I cannot promise anything.
The library now relies on the inference of ofetch for the content-type, as nothing else is currently possible. The parameter form-urlencoded
will hand over a URLSearchParams
object and the form
parameter a FormData
object to ofetch.
On older versions of keycloak that are facing error: 500 Token request failed on browser & ERROR [nuxt-oidc-auth]: { error: 'RESTEASY003065: Cannot consume content type' } on console
Cause : improper request-form data generation & header content-type json
fix:
1) use of URLSearchParams() class for request form generation instead of FormData() class 2) content-type to be explicity defined as "application/x-www-form-urlencoded" in the headers