Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:09
What would you like to do?
Bike Index strategy for python flask social
Some information about OAuth on the Bike Index available, srys, still under development
from social.backends.oauth import BaseOAuth2
class BikeIndexOAuth2(BaseOAuth2):
name = 'bikeindex'
ID_KEY = 'id'
DEFAULT_SCOPE = ['read_bikes']
('refresh_token', 'refresh_token', True),
('id', 'id'),
('bike_ids', 'bike_id')
def get_user_details(self, response):
"""Return user details from Bike Index account"""
name = response.get('name') or ''
return {'bike_ids': response.get('bike_ids')}
def user_data(self, access_token, *args, **kwargs):
"""Grab user profile information from Bike Index."""
response = self.get_json('',
params={'access_token': access_token})
if 'bike_ids' in response:
response = {
'bike_id': response['bike_ids']
return response
Copy link

Modeled after Amazon's strategy - you can view the Bike Index ruby strategy here

I put in a default_scope of read_bikes, even though that isn't the default scope because it's the scope that is going to be the most useful. But really, it should be public and you should add read_bikes and read_user when you create the app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment