generic-oauth2 icon indicating copy to clipboard operation
generic-oauth2 copied to clipboard

Parse URL Parameters Properly

Open jvartanian opened this issue 4 years ago • 1 comments

Currently, URL fragments are being treated as a part of the query string. These are two distinct pieces of a URL, and should be handled separately. This PR updates the logic within WebUtils.getUrlParams() to:

  • Parse the urlString using the Javascript URL interface. This interface properly separates the query string and fragment
  • If the URL doesn't contain a query string or a fragment, return undefined
  • If the URL contains a query string, parse its values, otherwise parse the fragment

jvartanian avatar Nov 02 '21 20:11 jvartanian

This resolves #182

jvartanian avatar Nov 02 '21 20:11 jvartanian

The example facebook Web flow also currently fails due to the returned response not being parsed correctly.

The Url from the provider/facebook is returned as:

http://localhost:3000/login?#access_token=...

Which then gets parsed as

{
  "#access_token": "..."
}

Which then thows ERR_NO_ACCESS_TOKEN as it doesn't expect to find the hash

mikemellor11 avatar Apr 10 '23 12:04 mikemellor11

Thanks for this PR

moberwasserlechner avatar Apr 11 '23 17:04 moberwasserlechner