<s> """<STR_LIT>""" <EOL> import django . core . exceptions <EOL> try : <EOL> from django . conf import settings <EOL> from django . contrib . auth import authenticate , login <EOL> except django . core . exceptions . ImproperlyConfigured : <EOL> pass <EOL> import logging <EOL> logger = logging . getLogger ( "<STR_LIT>" ) <EOL> class AboutyouMiddleware ( object ) : <EOL> """<STR_LIT>""" <EOL> def process_request ( self , request ) : <EOL> try : <EOL> user = None <EOL> if not request . user . is_authenticated ( ) : <EOL> access_token = None <EOL> if "<STR_LIT>" in request . META : <EOL> access_token = request . META [ "<STR_LIT>" ] . split ( '<STR_LIT:U+0020>' ) [ <NUM_LIT:1> ] <EOL> logger . debug ( '<STR_LIT>' , access_token ) <EOL> else : <EOL> code = request . GET . get ( '<STR_LIT:code>' ) <EOL> state = request . GET . get ( '<STR_LIT:state>' ) <EOL> if code and state : <EOL> redirect_uri = request . build_absolut_uri ( settings . AUTH_REDIRECT_PATH ) <EOL> access_token = settings . AUTH . access_token ( code , redirect_uri ) [ '<STR_LIT>' ] <EOL> if access_token : <EOL> user = authenticate ( access_token = access_token ) <EOL> if user is not None and not user . is_anonymous ( ) : <EOL> login ( request , user ) <EOL> except Exception : <EOL> logger . exception ( '<STR_LIT>' ) </s>
