#NEWLINE# def oauth_callback( request , service ) : #NEWLINE# #INDENT# local_host = utils . get_local_host ( request ) #NEWLINE# form = forms . OAuth2CallbackForm ( service = service , local_host = local_host , data = request . GET ) #NEWLINE# if form . is_valid ( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# user = form . get_authenticated_user ( ) #NEWLINE# #UNINDENT# except ValueError as e : #NEWLINE# #INDENT# messages . error ( request , smart_text ( e ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# auth_login ( request , user = e ) #NEWLINE# messages . success ( request , _ ( 'You are now logged in.' ) ) #NEWLINE# return redirect ( settings . LOGIN_REDIRECT_URL ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# for ( dummy_field , errors ) in form . errors . items ( ) : #NEWLINE# #INDENT# for error in errors : #NEWLINE# #INDENT# messages . error ( request , error ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return redirect ( 'registration:login' )