#NEWLINE# def _redirect( request , provider ) : #NEWLINE# #INDENT# p = settings . SANCTION_PROVIDERS [ provider ] #NEWLINE# c = SanctionClient ( auth_endpoint = p [ 'auth_endpoint' ] , client_id = p [ 'client_id' ] , token_endpoint = p [ 'token_endpoint' ] , client_secret = p [ 'client_secret' ] , resource_endpoint = p [ 'resource_endpoint' ] ) #NEWLINE# kwargs = p . get ( 'auth_params' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# response = redirect ( c . auth_uri ( redirect_uri = p [ 'redirect_uri' ] , scope = ( p [ 'scope' ] if ( 'scope' in p ) else None ) , ** kwargs ) ) #NEWLINE# if getattr ( settings , 'SANCTION_USE_CSRF' , True ) : #NEWLINE# #INDENT# CsrfViewMiddleware ( ) . process_view ( request , response , [ ] , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# url = list ( urlparse ( response [ 'location' ] ) ) #NEWLINE# urlp = dict ( parse_qsl ( url [ 4 ] ) ) #NEWLINE# urlp . update ( { #NEWLINE# #INDENT# 'state' : csrf . get_token ( request ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# url [ 4 ] = urlencode ( urlp ) #NEWLINE# response [ 'location' ] = urlunparse ( url ) #NEWLINE# #UNINDENT# return response