# Discourse redirects to the OAuth server after loading \`/?authComplete=true\`

**URL:** <https://meta.discourse.org/t/discourse-redirects-to-the-oauth-server-after-loading-authcomplete-true/115973>\
**Category:** SSO\
**Created:** [25.Апрель.2019 15:51:00 UTC](https://meta.discourse.org/t/discourse-redirects-to-the-oauth-server-after-loading-authcomplete-true/115973 "2019-04-25T15:51:00Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [30.Апрель.2019 18:53:35 UTC](https://meta.discourse.org/t/discourse-redirects-to-the-oauth-server-after-loading-authcomplete-true/115973/3 "2019-04-30T18:53:35Z")

</div>

I’m not sure exactly what’s going on. @ryancey if you are able to share a link to the site I’d be happy to take a quick look.

Some of the logic around redirection is in

> <https://github.com/discourse/discourse/blob/main/app/controllers/users/omniauth_callbacks_controller.rb#L54-L90>

We use the omniauth origin system, which uses the referrer to determine the user’s starting location: [Saving User Location · omniauth/omniauth Wiki · GitHub](https://github.com/omniauth/omniauth/wiki/Saving-User-Location).

That can be overridden by the `destination_url` cookie, or the `origin=` URL parameter. You could try using `https://[discourse-server]/auth/oauth2_basic?origin=/`, to ensure that your users always end up on the forum homepage.

I know @LeoMcA recently made some improvements here, so make sure you’re running a recent version of Discourse.

---

_[View the full topic](https://meta.discourse.org/t/discourse-redirects-to-the-oauth-server-after-loading-authcomplete-true/115973)._
