How to get response URL params after redirecting user with `window.location` property?

First things first, the link to the exercise/project in question: I am fighting with the jammming project (yes, both the infamous and famous one).

But, of course, I wouldn’t want anyone to just do the hard work for me. It’s just that the Web APIs are not taught at all in CC (only a link to MDN) and I am struggling a little bit with some things.

Right now, my doubt is because I am being instructed to redirect a user to a certain URL using the window.location property. Now, the interesting part is that this URL will in turn redirect the user to another URL that has this format: URL/#token=random_chars_here&token_type=Bearer&expires_in=3600.

Now, my question is how do I try to access the latest URL (and if you ask me why, it’s because I need to get the access token and the expiration time in there and use them)?

My thoughts and what I’ve tried:

  • I tried using fetch but it seems is not an option here since I am not actually fetching anything, but just being redirected.
  • I’ve tried using window.location.hash but it won’t return anything, I suspect because it’s parsing the current URL, which at the time I call the function is the one I sent the user to through window.location (mentioned above)
    *I’ve tried using recursion but, well… I got myself in trouble a little bit with insecure operation alerts :slight_smile:
    (recursion meaning if I don’t have an access token in the current URL, redirect the user and then return a call to the same function that should now have [I thought] the token in the current URL. I thought and I was wrong :slight_smile: )

I would really appreciate any explanation about it or pointers on what I could be doing/thinking wrong. Of course I have already been reading the window.location docs in MDN. That and some extra research gave me the idea of trying the hash property.

Thanks in advance for any and all help!