Search code examples
pythonflaskopenidsteam

Flask-OpenID Steam login 500 error


I am following this guide on how to sign in to Steam using Flask-OpenID: http://flask.pocoo.org/snippets/42/

The Flask app returns a 500 error when it encounters the following portion of code:

@app.route('/login')
@oid.loginhandler
def login():
    if g.user is not None:
        return redirect(oid.get_next_url())
    return oid.try_login('http://steamcommunity.com/openid')

Specifically the following line:

return oid.try_login('http://steamcommunity.com/openid')

I know the guide is quite outdated (dated 02-17-2011). Is there an updated guide out there or is there a fix for this error? I can't seem to find it.

For reference: https://pythonhosted.org/Flask-OpenID/#flask_openid.OpenID.try_login


Solution

  • Tried the app in debug mode and got the following error:

    RuntimeError: the session is unavailable because no secret key was set. Set the secret_key on the application to something unique and secret.

    Did a bit of googling and came up with a solution for this: secret key not set in flask session

    Ended up just adding the following line:

    app.secret_key = "super secret key goes here"
    

    This has fixed my 500 error issue; finally getting an actual redirect to the steam login page.