I posted something earlier that at least gave me a direction, but I am stuck again. I want to use the Discord API as a login for my website, then later (after someone fills out a form), take that person’s Discord username and put it in a SQL database along with other information.
Right now, I got the Discord login going through OAuth2 but I cannot get past the login. I tried authorizing the token but that isnt working. If someone could help, I would be very appreciative!
Here’s the code from config.py (actually taken from the Discord Dev Portal to see if I could get it to work)
class get_token():
def get_token(code: str):
data = {
'grant_type': 'authorization_code',
'code': code,
'redirect_uri': REDIRECT_URI,
'scope': 'identify guilds'
}
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
resp = requests.post("OAUTH_URL", data=data, headers=headers)
resp.raise_for_status()
return resp.json()
And here’s my code from app.py
@app.route('/oauth/discord')
def auth(get_token):
if request.method == 'POST':
return redirect('https://discordapp.com/api/users/@me')
Right now, if I redirect to https://discordapp.com/api/users/@me it SHOULD give me data from the login, but it does not.
My console spits this out as the last line: TypeError: auth() missing 1 required positional argument: ‘get_token’
Thank you so much for any help at all!