I use OAuth Implicit flow authentication method in my Angular application. To retrieve access token I need to parse parameters from following string:
http://localhost/authentication#access_token={0}&expires_in={1}&user_id={2}
After some investigation I did not find any mechanisms to retrieve parameters from such URLs (all mechanisms which I found are based on using manual string splitting. Does it mean that Angular doesn't have "out of the box" mechanisms to parse parameters from URL fragment and the best way to do this is use substring()
or split()
method?
If you want to get the query parameters, replace
this.activatedRoute.params
withthis.activatedRoute.queryParams
.You can do it using the
ActivatedRoute
:To retrieve query parameters, just replace
fragment
byqueryParams
on this code.