title: AngularJS: How to clear query parameters in the URL?
body: <p>My AngularJS application needs to have access to the user's LinkedIn profile. In order to do that I need to redirect the user to a LinkedIn URL which contains a callback redirect_uri parameter which will tell LinkedIn to redirect the user back to my webapp and include a "code" query param in the URL. It's a traditional Oauth 2.0 flow.</p>
  
  <p>Everything works great except that LinkedIn redirects the user back to the following URL:</p>
  
  <pre><code>http://localhost:8080/?code=XXX&amp;state=YYY#/users/123/providers/LinkedIn/social-sites
  </code></pre>
  
  <p>I would like to remove <code>?code=XXX&amp;state=YYY</code> from the URL in order to make it clean. The user does not need to see the query parameters I received from LinkedIn redirect. </p>
  
  <p>I tried <code>$location.absUrl($location.path() + $location.hash()).replace()</code>, but it keep the query params in the URL.</p>
  
  <p>I am also unable to extract the query parameters, e.g. "code", using <code>($location.search()).code</code>.
  It seems like having ? before # in the URL above is tricking Angular.</p>