# OAuth-accountaanmaak mislukt door CSRF-detectie direct na het inloggen op Auth0 in dezelfde browser

**URL:** <https://meta.discourse.org/t/oauth-account-creation-fails-due-to-csrf-detection-immediately-after-logging-into-auth0-on-same-browser/249112>\
**Category:** SSO\
**Tags:** oauth2\
**Created:** [16 december 2022 om 10:31 UTC](https://meta.discourse.org/t/oauth-account-creation-fails-due-to-csrf-detection-immediately-after-logging-into-auth0-on-same-browser/249112 "2022-12-16T10:31:57Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![joellabes](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joellabes/32/272968_2.png) [@joellabes](https://meta.discourse.org/u/joellabes)\
**Post date:** [16 december 2022 om 10:31 UTC](https://meta.discourse.org/t/oauth-account-creation-fails-due-to-csrf-detection-immediately-after-logging-into-auth0-on-same-browser/249112/1 "2022-12-16T10:31:58Z")

</div>

We have configured the oauth2 plugin following the directions on [Configure sign up and log in with Auth0 using the OAuth2 Basic Plugin](https://meta.discourse.org/t/configure-sign-up-and-log-in-with-auth0-using-the-oauth2-basic-plugin/64633).

The flow works as follows:

- Users sign up at [https://getdbt.com/community/join-the-community](https://getdbt.com/community/join-the-community)
- They get sent a confirmation email from Auth0
- They land on [https://getdbt.com/community/email-verified](https://getdbt.com/community/email-verified)
- They click _Get help on the community forum_, and are taken to Auth0 to sign in
- After signing in, they are redirected to [discourse.getdbt.com](http://discourse.getdbt.com) but with the CSRF warning displayed.

If they click _Log In_ and then _Use your dbt Community Account_, the **account is successfully created** and they see the account creation dialog where they can set their username etc.

Loom video showing this in action:  
https://www.loom.com/embed/88c95b2cdb074328b380960653469988

I have enabled `oauth2 debug auth` and in the logs can see `(oauth2_basic) Authentication failure! csrf_detected: OmniAuth::Strategies::OAuth2::CallbackError, csrf_detected | CSRF detected`

My questions:

1. Is this a Discourse issue or an Auth0 issue? I assume Discourse since a basically identical login flow for Slack works without issue.
2. Why does this work on the Login page but not when login is triggered from the Auth0 side?
3. The default CSRF error message implies that it happens when the browser changes, or when the login flow takes too long. Neither of those are the case, what else could be causing it?

---

_[View the full topic](https://meta.discourse.org/t/oauth-account-creation-fails-due-to-csrf-detection-immediately-after-logging-into-auth0-on-same-browser/249112)._
