user12757
user12757

Reputation: 39

Google Oauth2 provider not implemented

I am working in django 1.6. My app requires social authentication, so I am using django-social-auth app. I am trying to list all the friends in my google account. I followed the steps as indicated in the url : http://c2journal.com/2013/01/24/social-logins-with-django/

Inorder to list all my friends I used django-social-friends-finder. I created a google api project and used the client id and secret key in GOOGLE_OAUTH2_CLIENT_ID and GOOGLE_OAUTH2_CLIENT_SECRET in my settings.py file. I gave my localhost ip for the redirect_uri parameter.

I successfully authenticated using my email, but could not list my friends list. When I debugged in the terminal error message is displaying as 'provider: %s is not implemented'. I searched a lot but couldn't find a solution. Please help me out. Thanks in advance.

Upvotes: 0

Views: 309

Answers (1)

omab
omab

Reputation: 3701

Never used django-social-friends-finder, but I guess it calls https://www.googleapis.com/plus/v1/people/me/people/visible at some point to retrieve your friends list. But to access that API you need to specify the correct scope, that way your access token has permissions for it. To do so in django-social-auth define this setting:

GOOGLE_OAUTH_EXTRA_SCOPE = [
    'https://www.googleapis.com/auth/plus.login'
]

Also this snippet shows how you can retrieve your friends list:

import requests

user = User.objects.get(...)
social = user.social_auth.get(provider='google-oauth2')
response = requests.get(
    'https://www.googleapis.com/plus/v1/people/me/people/visible',
    params={'access_token': social.extra_data['access_token']}
)
friends = response.json()['items']

Upvotes: 1

Related Questions