Permalink
Browse files

l

  • Loading branch information...
melpomene committed Mar 31, 2012
1 parent 7f52ad0 commit 089d46a0bfd7af98029caf5a1cdf9378fe4d7e34
Showing with 9 additions and 11 deletions.
  1. +3 −2 facebook.py
  2. +2 −1 main.py
  3. 0 recommend.py
  4. +4 −8 view.py
View
@@ -18,7 +18,7 @@ def get_friends(self):
for friend in jr["data"]:
print friend["name"] + "\n"
- def get_books(self, friend_id):
+ def get_books(self, friend_id="me"):
query_url = baseurl +str(friend_id) + '/books' + access_token + self.access_token
r = requests.get(query_url)
if r.status_code != 200:
@@ -27,7 +27,8 @@ def get_books(self, friend_id):
jr = json.load(r.content):
for book in jr["data"]:
print book['name'] + '\n'
-
+
+
View
@@ -17,13 +17,14 @@
class index:
def GET(self):
+ return session.auth_token
return render.base(view.index(session.auth_token))
class callback:
""" Callback from facebook oauth 2 """
def GET(self):
ans = web.input(secret = "")
- return render.base(view.callback(code=str(ans.code)))
+ return render.base(view.callback(code=str(ans.code), session=session))
class auth:
"""Promt for facebook login"""
View
No changes.
View
12 view.py
@@ -1,4 +1,4 @@
-import web, ConfigParser, urlparse
+import web, ConfigParser, urlparse, tempfile
import auth as oauth2
config = ConfigParser.RawConfigParser()
@@ -15,12 +15,8 @@ def index(**k):
def callback(**k):
fb = oauth2.FacebookAuth(FACEBOOK_ID, FACEBOOK_SECRET, "http://localhost:8080/callback")
response = urlparse.parse_qs(fb.request_access_token(k['code']))
- web.config.session_parameters.handler = 'file'
- web.config.handler_parameters.file_prefix = 'sess'
- web.config.handler_parameters.file_dir = '/tmp'
- s = web.ctx.session
- s.start()
- s.auth_token = response
+ session = k['session']
+ session["access_token"] = response['access_token']
+ session["expires"] = response['expires']
- print s.auth_token
return render.callback()

0 comments on commit 089d46a

Please sign in to comment.