Last active
August 29, 2015 14:17
-
-
Save tejovanthn/f2eae0cee36f54d6fb56 to your computer and use it in GitHub Desktop.
authomatic test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from authomatic import Authomatic | |
authomatic = Authomatic(app.config['AUTHOMATIC'], app.config['SECRET_KEY'], report_errors=False) | |
@user.route('/login/<provider_name>/', methods=['GET', 'POST']) | |
def login_social(provider_name): | |
""" | |
Login handler, must accept both GET and POST to be able to use OpenID. | |
From the example at http://peterhudec.github.io/authomatic/examples/flask-simple.html | |
""" | |
response = make_response() | |
result = authomatic.login(WerkzeugAdapter(request, response), | |
provider_name, session=session, | |
session_saver=lambda : \ | |
app.save_session(session, response)) | |
if result: | |
if result.user: | |
result.user.update() | |
g.user = result.user | |
# <my changes> | |
r = authomatic.access(g.user.credentials, url="https://graph.facebook.com/me/friends") | |
print r.data | |
# returns: {u'data': [], u'summary': {u'total_count': 1500}} | |
# I have 'scope': ['email', 'user_friends'], defined in the config. | |
# Am I using authomatic.access() wrong? | |
# </my changes> | |
return render_template('user/login_social.html', result=result) | |
return response | |
I get r.status
as 200
It's the same with the result.provider.access()
.
The app permissions are the default ones right? The ones when you create, or do i need to add some other permissions?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Everything seems to be OK in your code. The access call seems to be successful (check
r.status
), but myr.data
looks like this (there's nosummary
key):BTW you can also call access like this:
Are you sure that you have friends on facebook? (just kidding 😄)