Reputation: 18657
I'm using Flask-OIDC and, as an example, I have a route:
@app.route('/')
@oidc.require_login
def home():
print('hi there')
Inside my application code/routes I only know that the user is authenticated. How can I know when a user has been authenticated?
We are using Okta hosted authentication (I don't think anything in this flow is specific to Okta) so the user is redirected to the Okta site and then redirected to our site with a token when successfully authenticated on their side. From what I understand the flow is like this:
I want to hook into step 5 so that I can run some code when the user is successfully authenticated. How do I do that?
Upvotes: 0
Views: 583
Reputation: 13069
From Flask documentation,
accept_token(require_token=False, scopes_required=None, render_errors=True)
Use this to decorate view functions that should accept OAuth2 tokens, this will most likely apply to API functions.
Tokens are accepted as part of the query URL (access_token value) or a POST form value (access_token).
Once user has successfully complete the OIDC flow, you application receive the OIDC (OAuth 2.0 as stated document) tokens from OKta. For requirement of step 5, you need to tap into this response handling method.
p.s - Found a code snippet as a reference.
Upvotes: 1