#NEWLINE# def get_access_token( user ) : #NEWLINE# #INDENT# key = str ( user . id ) #NEWLINE# access_token = cache . get ( key ) #NEWLINE# if ( access_token is None ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# social_user = ( user . social_user if hasattr ( user , 'social_user' ) else UserSocialAuth . objects . get ( user = user . id , provider = FacebookBackend . name ) ) #NEWLINE# #UNINDENT# except UserSocialAuth . DoesNotExist : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# if social_user . extra_data : #NEWLINE# #INDENT# access_token = social_user . extra_data . get ( 'access_token' ) #NEWLINE# expires = social_user . extra_data . get ( 'expires' ) #NEWLINE# cache . set ( key , expires , ( int ( expires ) if ( expires is not None ) else 0 ) ) #NEWLINE# #UNINDENT# #UNINDENT# return access_token