# Login flow (Flask -\> Discourse -\> Flask) with OAuth

**URL:** https://meta.discourse.org/t/login-flow-flask-discourse-flask-with-oauth/162153
**Category:** Development
**Tags:** sso, discourseconnect
**Created:** [August 26, 2020, 4:42pm UTC](https://meta.discourse.org/t/login-flow-flask-discourse-flask-with-oauth/162153 "2020-08-26T16:42:15Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![\_nix](https://avatars.discourse-cdn.com/v4/letter/_/a87d85/32.png) [@\_nix](https://meta.discourse.org/u/_nix)
#### Post date: [August 26, 2020, 4:42pm UTC](https://meta.discourse.org/t/login-flow-flask-discourse-flask-with-oauth/162153/1 "2020-08-26T16:42:15Z")

</div>

Hi there!

I have two questions that are related, hopefully someone can help 🙂

I’ve configured my Discourse instance to support OAuth via Twitter, Facebook, and Google. What I’m looking to do is the following:

Scenario 1:

1. User lands on `/home` (Python/Flask app)
2. They want to sign up for a Discourse account.
3. They get redirected to the appropriate OAuth flow, e.g. `https://discourse.example.com/auth/google`.
4. **Can I redirect them back to `/home` once they complete their registration?**

Scenario 2:

1. User lands on `/home` (Python/Flask app)
2. They _already_ have a Discourse account.
3. They want to sign in on the main app using OAuth in order to access some protected page.
4. They get redirected to the appropriate OAuth flow.
5. **Can I redirect them to `/user` once Discourse has verified their account credentials?**

Please let me know if anything is unclear and I will be happy to elaborate!

Thanks!

---

<div class="post-metadata">

### Author: ![rishabh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rishabh/32/179446_2.png) [@rishabh](https://meta.discourse.org/u/rishabh)
#### Post date: [August 27, 2020, 12:19pm UTC](https://meta.discourse.org/t/login-flow-flask-discourse-flask-with-oauth/162153/2 "2020-08-27T12:19:38Z")

</div>

Just in case you haven’t seen it yet, our documentation is at [Discourse OAuth2 Basic](https://meta.discourse.org/t/oauth2-basic-support/33879/). Does that have some of the answers you’re looking for?

---

<div class="post-metadata">

### Author: ![\_nix](https://avatars.discourse-cdn.com/v4/letter/_/a87d85/32.png) [@\_nix](https://meta.discourse.org/u/_nix)
#### Post date: [August 27, 2020, 2:39pm UTC](https://meta.discourse.org/t/login-flow-flask-discourse-flask-with-oauth/162153/3 "2020-08-27T14:39:23Z")

</div>

Thanks for the reply @rishabh!

Unfortunately as far as I can tell the documentation doesn’t cover my questions. My OAuth configurations _are_ working as expected, it’s only the additional functionality outlined in scenarios 1 & 2 that cause trouble.

What I’m looking for is something along the lines of an optional parameter, `callback_url`, that would redirect the user to its target URL, _after_ the OAuth provider has verified their account, and returned them to Discourse.

I guess it’s sort of as if my Discourse instance acted as an OAuth provider in and of itself, for my Flask/Python app?

E.g. `https://discourse.example.com/auth/google?callback_url=https://example.com/home` takes the user to Google, returns them to Discourse, which in turn redirects them to `callback_url`.
