#NEWLINE# def authenticate( self , google_oauth2_token = None , return_data = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# token_payload = googleapiclient . verify_id_token ( google_oauth2_token , settings . GOOGLE_CLIENT_ID ) #NEWLINE# #UNINDENT# except AppIdentityError : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# if ( token_payload [ 'email_verified' ] in ( True , 'true' ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return get_user_profile_by_email ( token_payload [ 'email' ] ) #NEWLINE# #UNINDENT# except UserProfile . DoesNotExist : #NEWLINE# #INDENT# return_data [ 'valid_attestation' ] = True #NEWLINE# return None #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# return_data [ 'valid_attestation' ] = False