Hi,
I am researching the feasibility of moving our authentication to Okta.
Since our existing backend server is written in python (flask), I followed this guide to get familiar with the flask-okta integration:
The tutorial is very helpful, but the logout doesn’t work as expected. Even after clicking on the “logout” button, one can hit the /dashboard endpoint and immediately get auto-verified as long as user is logged in to okta.
I did some looking around and I found this thread:
it seems like they were having the exact same issue that I’m facing, however unlike the resolution on that thread, I’m still unable to successfully logout users from okta.
I’m follwoing the API reference as outlined by OpenID Connect & OAuth 2.0 API | Okta Developer
I have this logout endpoint in the flask server:
@app.route("/auth/logout/")
@oidc.require_login
def logout():
info = oidc.user_getinfo(['preferred_username', 'email', 'sub'])
from oauth2client.client import OAuth2Credentials
id_token = OAuth2Credentials.from_json(oidc.credentials_store[info.get('sub')]).token_response['id_token']
logout_request = 'https://dev-2210127.okta.com/logout?id_token_hint={}'.format(id_token)
oidc.logout()
return redirect(logout_request)
when the user is logged in, I am able to successfully obtain the id_token, but when I end up redirecting to
the endpoint, I get 404 errors and the user doesn’t get logged out.
please note I have tried to GET https://dev-2210127.okta.com/logout?id_token_hint={TOKEN}
as well as https://dev-2210127.okta.com/v1/logout?id_token_hint={TOKEN} since the documentation is not very clear if the /v1
is necessary.
both redirects take me to the okta subdomain, but they both return 401 presumably because they can’t find logged in user with the token. any help is appreciated
Thanks