Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moved fields descriptions to docstring and changed some default values.

  • Loading branch information...
commit 84e57e7d5e33f8f3661315278b6aff67e4cd19d8 1 parent fded717
@mihanovak authored
Showing with 18 additions and 19 deletions.
  1. +18 −19 piplmesh/account/backends.py
View
37 piplmesh/account/backends.py
@@ -110,6 +110,19 @@ def authenticate(self, twitter_token, request):
class FoursquareBackend(MongoEngineBackend):
"""
Foursquare authentication.
+
+ Foursquare user fields are:
+ id - A unique identifier for this user.
+ firstName - A user's first name.
+ lastName - A user's last name.
+ homeCity - User's home city.
+ photo - URL of a profile picture for this user.
+ gender - A user's gender: male, female, or none.
+ relationship - (Optional) The relationship of the acting user (me) to this user (them).
+
+ Fields present in user details:
+ type, contact, pings, badges, checkins, mayorships, tips, todos, photos, friends, followers,
+ requests, pageInfo.
"""
def authenticate(self, foursquare_token, request):
@@ -130,30 +143,16 @@ def authenticate(self, foursquare_token, request):
data = urllib.urlopen('https://api.foursquare.com/v2/users/self?%s' % urllib.urlencode({'oauth_token': access_token}))
foursquare_data = json.load(data)
foursquare_user = foursquare_data['response']['user']
- """
- Fields in foursquare_user:
- id - A unique identifier for this user.
- firstName - A user's first name.
- lastName - A user's last name.
- homeCity - User's home city.
- photo - URL of a profile picture for this user.
- gender - A user's gender: male, female, or none.
- relationship - (Optional) The relationship of the acting user (me) to this user (them).
-
- Present in user details:
- type, contact, pings, badges, checkins, mayorships, tips, todos, photos, friends, followers,
- requests, pageInfo.
- """
user, created = self.user_class.objects.get_or_create(
foursquare_id=foursquare_user.get('id'),
defaults={
- 'username': foursquare_user.get('firstName', {}) + foursquare_user.get('lastName', {}),
- 'first_name': foursquare_user.get('firstName', {}),
- 'last_name': foursquare_user.get('lastName', {}),
+ 'username': foursquare_user.get('firstName', '') + foursquare_user.get('lastName', ''),
+ 'first_name': foursquare_user.get('firstName', ''),
+ 'last_name': foursquare_user.get('lastName', ''),
'email': foursquare_user.get('contact', {}).get('email'),
- 'gender': foursquare_user.get('gender', {}),
- 'foursquare_picture_url': foursquare_user.get('photo', {})
+ 'gender': foursquare_user.get('gender'),
+ 'foursquare_picture_url': foursquare_user.get('photo')
}
)
user.foursquare_token = access_token
Please sign in to comment.
Something went wrong with that request. Please try again.