def get_oauth_token(oauth_code): print "get_oauth_token()" okta_util = OktaUtil(request.headers, config.okta) oauth_token_response_json = okta_util.get_oauth_token( oauth_code, config.okta["redirect_uri"]) print "oauth_token_response_json: {0}".format(oauth_token_response_json) return oauth_token_response_json["access_token"]
def oidc(): print "oidc()" print request.form redirect_url = "" if("error" in request.form): oauth_token = "NO_TOKEN" redirect_url = config.okta["app_host"] else: okta_util = OktaUtil(request.headers, config.okta) oidc_code = request.form["code"] print "oidc_code: {0}".format(oidc_code) oauth_response = okta_util.get_oauth_token(oidc_code, config.okta["redirect_uri"]) print "oauth_response: {0}".format(json.dumps(oauth_response, indent=4, sort_keys=True)) oauth_token = oauth_response["id_token"] redirect_url = config.okta["post_oidc_redirect"] response = make_response(redirect(redirect_url)) response.set_cookie('token', oauth_token) return response