<s> from flask import session <EOL> from flask . ext . oauthlib . client import OAuth <EOL> from quokka . modules . accounts . oauth import make_oauth_handler , oauth_login <EOL> def configure ( app ) : <EOL> """<STR_LIT>""" <EOL> app . add_quokka_url_rule ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> oauth_login <EOL> ) <EOL> config = app . config . get ( "<STR_LIT>" ) <EOL> if not config : <EOL> return <EOL> oauth = OAuth ( app ) <EOL> for provider , data in config . items ( ) : <EOL> provider_name = "<STR_LIT>" + provider <EOL> oauth_app = oauth . remote_app ( <EOL> provider , <EOL> ** { k : v for k , v in data . items ( ) if not k . startswith ( "<STR_LIT:_>" ) } <EOL> ) <EOL> token_var = "<STR_LIT>" . format ( provider ) <EOL> oauth_app . tokengetter ( lambda : session . get ( token_var ) ) <EOL> setattr ( app , provider_name , oauth_app ) <EOL> app . add_quokka_url_rule ( <EOL> '<STR_LIT>' . format ( provider ) , <EOL> '<STR_LIT>' . format ( provider ) , <EOL> oauth_app . authorized_handler ( make_oauth_handler ( provider ) ) <EOL> ) <EOL> if provider == '<STR_LIT>' : <EOL> def change_linkedin_query ( uri , headers , body ) : <EOL> auth = headers . pop ( '<STR_LIT>' ) <EOL> headers [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if auth : <EOL> auth = auth . replace ( '<STR_LIT>' , '<STR_LIT>' ) . strip ( ) <EOL> if '<STR_LIT:?>' in uri : <EOL> uri += '<STR_LIT>' + auth <EOL> else : <EOL> uri += '<STR_LIT>' + auth <EOL> return uri , headers , body <EOL> oauth_app . pre_request = change_linkedin_query </s>
