Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:17
Show Gist options
  • Save tejovanthn/f2eae0cee36f54d6fb56 to your computer and use it in GitHub Desktop.
Save tejovanthn/f2eae0cee36f54d6fb56 to your computer and use it in GitHub Desktop.
authomatic test
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
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:
g.user = result.user
# <my changes>
r = authomatic.access(g.user.credentials, url="")
# 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
Copy link

Everything seems to be OK in your code. The access call seems to be successful (check r.status), but my looks like this (there's no summary key):

    u'data': [
        {u'id': u'###', u'name': u'User Name 1'},
        {u'id': u'###', u'name': u'User Name 2'},
        {u'id': u'###', u'name': u'User Name 3'},
        # ...
    u'paging': {
        u'next': u''

BTW you can also call access like this:

r = result.provider.access("")

Are you sure that you have friends on facebook? (just kidding 😄)

Copy link

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