singingwolfboy / flask-dance

Doing the OAuth dance with style using Flask, requests, and oauthlib.
https://pypi.python.org/pypi/Flask-Dance/
MIT License
1.01k stars 158 forks source link

Discord oauth2 not working properly #341

Closed mrsrmn closed 3 years ago

mrsrmn commented 3 years ago

When I try to login into my website, it logs in. But when I click an another link that needs my discord login, I need to login again for some reason and its just an infinite loop. How can I fix this?

singingwolfboy commented 3 years ago

Sounds like the OAuth information is not being saved, or is not correctly associated with the user. What token storage are you using? Have you compared your code to some of the same quickstarts, such as https://github.com/singingwolfboy/flask-dance-google-sqla ?

mrsrmn commented 3 years ago

we are using flask session for storage

singingwolfboy commented 3 years ago

@michaeldel, you're the maintainer for the Discord provider. Do you have any idea what's going on here?

mrsrmn commented 3 years ago

@singingwolfboy We fixed the issue by using Flask-SqlAlchemy but there is still an another problem. Flask-Dance doesn't add more than 1 entries to the DB. How can we fix this?

image

This is how the DB looks like all the time. Only 1 entry

singingwolfboy commented 3 years ago

@MakufonSkifto It looks like you don't have a user_id column for your table when you're storing OAuth tokens. Without a user_id column, you can't associate OAuth tokens with users. Please make sure you've read the documentation for using the SQLAlchemy token storage, as well as the documentation for multi-user setups.

mrsrmn commented 3 years ago

@singingwolfboy Do i need to store the logged in users in an another DB / Table (using an another class)? It looks like I do and I really don't want to do that.

singingwolfboy commented 3 years ago

@MakufonSkifto Yes, you do.

At this point, the topic of this issue has changed from "Discord OAuth isn't working" to "I need support with configuring Flask-Dance". I suggest that you review the documentation and the sample projects, such as the https://github.com/singingwolfboy/flask-dance-google-sqla project that I linked you to earlier. If you still have questions, please open a new issue.