Skip to content

Instantly share code, notes, and snippets.

@alejandrobernardis
Created August 29, 2012 06:16
Show Gist options
  • Select an option

  • Save alejandrobernardis/3507382 to your computer and use it in GitHub Desktop.

Select an option

Save alejandrobernardis/3507382 to your computer and use it in GitHub Desktop.
Tornado Web Server, Fix Facebook App IE
class OAuth2Mixin(object):
"""Abstract implementation of OAuth v 2."""
def authorize_redirect(self, redirect_uri=None, client_id=None,
client_secret=None, extra_params=None):
"""Redirects the user to obtain OAuth authorization for this service.
Some providers require that you register a Callback
URL with your application. You should call this method to log the
user in, and then call get_authenticated_user() in the handler
you registered as your Callback URL to complete the authorization
process.
"""
args = {
"redirect_uri": redirect_uri,
"client_id": client_id
}
if extra_params:
args.update(extra_params)
# fix FACEBBOK #########################################################
"""def is_msie(self):
user_agent = self.request.headers["User-Agent"]
if 'msie' in user_agent.lower():
return True
return False
def msie_header_fix(self):
if self.is_msie():
self.set_header("P3P", 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"')
"""
self.msie_header_fix()
# fix FACEBBOK #########################################################
self.redirect(
url_concat(self._OAUTH_AUTHORIZE_URL, args))
def _oauth_request_token_url(self, redirect_uri=None, client_id=None,
client_secret=None, code=None,
extra_params=None):
url = self._OAUTH_ACCESS_TOKEN_URL
args = dict(
redirect_uri=redirect_uri,
code=code,
client_id=client_id,
client_secret=client_secret,
)
if extra_params:
args.update(extra_params)
return url_concat(url, args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment