title: How to get access token in Web Api OAuth?
body: <p>I have a Web Application that generates the link to get an access token against a web API 2. </p>
  
  <p>Basically, the following controller action is called:</p>
  
  <p><code>GetExternalLogin</code> at <code>AccountController</code>:</p>
  
  <pre><code> ApplicationUser user = await UserManager.FindAsync(new UserLoginInfo(externalLogin.LoginProvider,
              externalLogin.ProviderKey));
  
          bool hasRegistered = user != null;
  
          if (hasRegistered)
          {
              Authentication.SignOut(DefaultAuthenticationTypes.ExternalCookie);
  
              ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(UserManager,
                 OAuthDefaults.AuthenticationType);
              ClaimsIdentity cookieIdentity = await user.GenerateUserIdentityAsync(UserManager,
                  CookieAuthenticationDefaults.AuthenticationType);
  
              AuthenticationProperties properties = ApplicationOAuthProvider.CreateProperties(user.UserName);
              Authentication.SignIn(properties, oAuthIdentity, cookieIdentity);
          }
          else
          {
        // as user is not registered, this block is hit
              IEnumerable&lt;Claim&gt; claims = externalLogin.GetClaims();
              ClaimsIdentity identity = new ClaimsIdentity(claims, OAuthDefaults.AuthenticationType);
              Authentication.SignIn(identity);
          }
  
          return Ok(); 
  </code></pre>
  
  <p>Now, this return Ok line simply returns to my Web API base url and add a token after this:</p>
  
  <pre><code>https://localhost:44301/#access_token=iPl1MSgnjI3oXgDxuCH9_t5I1SsELUH-v_vNXdehGpNWsCWsQaX7csWWadWRq4H2uZ0BB8zZm2s0xOI8TSOfgzH7QbFVko4Ui8jM5SylhPgkC7eiQG-kChDfa5HMlxKF1JvRg9Kvs40rPGqsC22uel-Gi2QZlrMh_5M0NT06QOOMv4bDTAFljKw9clsMiHidX4TPfQ6UmhROMIo8FcBDlAfH7wZbSQZjFAWm4Mub-oMoUxUOzAVxJrjGiM9gxwk4iqLqGbcFVl6AncJnFO_YDtmWH_sRBvmbfzpQ6GiB10eyY-hA_L-sWtQbX8IPPtOKuWGbyg0_MfaWBfAJfUiNjH6_VjcOfPEdwUPEvbnR8vw&amp;token_type=bearer&amp;expires_in=1209600&amp;state=Qvlzg__CCwjCjaqEOInQw0__FprOykwROuAciRgDlIQ1
  </code></pre>
  
  <p>and that's all. </p>
  
  <p>How I get these parameters from the URL and process them? </p>
  
  <p>If I change the base URL to any other action I get the <code>"invalid_request"</code> error caused by calling uri is different that redirect_uri.</p>
  
  <p>So, how a client app gets the access token ?</p>
  
  <p>Any help or clarification will be really helpful.</p>