In [1]:
# due to the many changes to the lib, lets just run with the master branch off of github
import sys
sys.path.insert(0, '/Users/ajmendez/tmp/stravalib/')
In [33]:
import requests
from pymendez import auth
from stravalib.client import Client
from polyline.codec import PolylineCodec
In [ ]:
In [3]:
client_id, secret, code, token = auth('strava', ['client_id', 'secret', 'code', 'token'])
In [21]:
def _status():
response = requests.get('https://www.strava.com/api/v3/athlete', params=dict(access_token=token))
headers = response.headers
try:
print 'Usage: {} of {}'.format(headers['x-ratelimit-usage'], headers['x-ratelimit-limit'])
except KeyError as e:
print headers
_status()
In [6]:
client = Client()
if len(code) == 0:
authorize_url = client.authorization_url(client_id=client_id,
redirect_uri='http://localhost:8282/authorized')
print authorize_url
code = raw_input('What was the code in the url bar? ').strip()
token = client.exchange_code_for_token(client_id=client_id, client_secret=secret, code=code)
print access_token
print ' Please update the code: {} and token: {}'.format(code, token)
else:
print 'already authorized'
client.access_token = token
In [7]:
athlete = client.get_athlete()
In [8]:
activities = client.get_activities()
In [9]:
activity = next(activities)
In [34]:
polycodec = PolylineCodec()
polycodec.decode(activity.map.summary_polyline)
Out[34]:
In [ ]: