Merge pull request #60 from michele-comitini/master

oauth 2 fixes
This commit is contained in:
mdipierro
2013-03-08 10:13:17 -08:00
2 changed files with 5 additions and 10 deletions
@@ -15,8 +15,6 @@ Dependencies:
import oauth2 as oauth import oauth2 as oauth
import cgi import cgi
from urllib2 import urlopen
import urllib2
from urllib import urlencode from urllib import urlencode
from gluon import current from gluon import current
@@ -64,9 +62,7 @@ class OAuthAccount(object):
Appends the _next action to the generated url so the flows continues. Appends the _next action to the generated url so the flows continues.
""" """
r = self.request r = self.request
http_host = r.env.http_x_forwarded_for http_host = r.env.http_host
if not http_host:
http_host = r.env.http_host
url_scheme = r.env.wsgi_url_scheme url_scheme = r.env.wsgi_url_scheme
if next: if next:
@@ -103,9 +103,7 @@ server for requests. It can be used for the optional"scope" parameters for Face
""" """
r = current.request r = current.request
http_host = r.env.http_x_forwarded_for http_host = r.env.http_host
if not http_host:
http_host = r.env.http_host
if r.env.https == 'on': if r.env.https == 'on':
url_scheme = 'https' url_scheme = 'https'
@@ -163,7 +161,7 @@ server for requests. It can be used for the optional"scope" parameters for Face
open_url = None open_url = None
opener = self.__build_url_opener(self.token_url) opener = self.__build_url_opener(self.token_url)
try: try:
open_url = opener.open(self.token_url, urlencode(data)) open_url = opener.open(self.token_url, urlencode(data), self.socket_timeout)
except urllib2.HTTPError, e: except urllib2.HTTPError, e:
tmp = e.read() tmp = e.read()
raise Exception(tmp) raise Exception(tmp)
@@ -208,7 +206,7 @@ server for requests. It can be used for the optional"scope" parameters for Face
def __init__(self, g=None, def __init__(self, g=None,
client_id=None, client_secret=None, client_id=None, client_secret=None,
auth_url=None, token_url=None, **args): auth_url=None, token_url=None, socket_timeout=60, **args):
""" """
first argument is unused. Here only for legacy reasons. first argument is unused. Here only for legacy reasons.
""" """
@@ -224,6 +222,7 @@ server for requests. It can be used for the optional"scope" parameters for Face
self.auth_url = auth_url self.auth_url = auth_url
self.token_url = token_url self.token_url = token_url
self.args = args self.args = args
self.socket_timeout = socket_timeout
def login_url(self, next="/"): def login_url(self, next="/"):
self.__oauth_login(next) self.__oauth_login(next)