#NEWLINE# def step2_live( request ) : #NEWLINE# #INDENT# constants = settings . CONSTANTS #NEWLINE# STEP_2_TEMPLATE_NAME = constants [ 'STEP_2_TEMPLATE_NAME_LIVE' ] #NEWLINE# STEP_3_TEMPLATE_NAME = constants [ 'STEP_3_TEMPLATE_NAME_LIVE' ] #NEWLINE# BASE_TOKEN_URL = constants [ 'BASE_TOKEN_URL' ] #NEWLINE# REDIRECT_URI = constants [ 'REDIRECT_URI_LIVE' ] #NEWLINE# CLIENT_ID = constants [ 'CLIENT_ID' ] #NEWLINE# CLIENT_KEY = constants [ 'CLIENT_KEY' ] #NEWLINE# RESOURCE_URI = constants [ 'RESOURCE_URI' ] #NEWLINE# context = { #NEWLINE# #INDENT# 'initialize' : '' , #NEWLINE# #UNINDENT# } #NEWLINE# azure_session = OAuth2Session ( CLIENT_ID , redirect_uri = REDIRECT_URI ) #NEWLINE# if ( request . method == 'GET' ) : #NEWLINE# #INDENT# aad_code = request . GET . get ( 'code' , '' ) #NEWLINE# request . session [ 'aad_code' ] = aad_code #NEWLINE# context [ 'aad_code' ] = aad_code #NEWLINE# return render ( request , STEP_2_TEMPLATE_NAME , context ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# aad_code = request . session [ 'aad_code' ] #NEWLINE# resource_name = request . session [ 'resource_name' ] #NEWLINE# token_dict = azure_session . fetch_token ( ( BASE_TOKEN_URL % resource_name ) , code = aad_code , client_secret = CLIENT_KEY , resource = RESOURCE_URI ) #NEWLINE# request . session [ 'token' ] = token_dict #NEWLINE# context [ 'token' ] = token_dict #NEWLINE# return render ( request , STEP_3_TEMPLATE_NAME , context )