Created
February 2, 2019 17:31
-
-
Save ricardochaves/ec73606ca9d46dcff214474befe37d0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route("/getAToken") | |
def main_logic(): | |
code = flask.request.args["code"] | |
state = flask.request.args["state"] | |
if state != flask.session["state"]: | |
raise ValueError("State does not match") | |
auth_context = adal.AuthenticationContext(AUTHORITY_URL) | |
token_response = auth_context.acquire_token_with_authorization_code( | |
code, REDIRECT_URI, config.RESOURCE, config.CLIENT_ID, config.CLIENT_SECRET | |
) | |
# It is recommended to save this to a database when using a production app. | |
flask.session["access_token"] = token_response["accessToken"] | |
return flask.redirect("/privateurl") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment