oauth 2.0 - Get location fragment with Fetch API redirect response -


i trying redirect response location fragment of fetch api request. can't figure how access it, if possible.

the context doing openid connect request in implicit flow, webrtc identity proxy assertion generation. oidc specs define answer of request as:

when using implicit flow, response parameters added fragment component of redirection uri

http/1.1 302 found location: https://client.example.org/cb# access_token=slav32hkkg ...

so i'm making request fetch set in manual mode. response opaque-redirect filtered response, hides location header. (https://fetch.spec.whatwg.org/#concept-filtered-response-opaque-redirect)

other mode fetch error , follow not help. while xhr automatically follows redirect not either. may missing fetch api, seems hidden on purpose.

could gives me way access information (or confirmation it's impossible) ?

is there alternative fetch , xhr make request, allow access redirect location header?

since xhr automatically / opaquely follows redirects (in event you're using whatwg-fetch polyfill example), 1 possible solution check response.url of fetch resolution, see if matches redirect location expect.

this helps if possible redirect locations limited or match pattern --- instance, if expect @ time redirect /login:

function fetchmiddleware(response) {   const = document.createelement('a');   a.href = response.url;   if (a.pathname === '/login') {     // ...   } else {     return response;   } }  fetch(`/api`)   .then(fetchmiddleware)   .then(function (response) {     // ...   }); 

Comments