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()


Usage: 8,19 of 600,30000

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


already authorized

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]:
[(39.34384, -76.63875),
 (39.3425, -76.63908),
 (39.34233, -76.63841),
 (39.34306, -76.63693),
 (39.34248, -76.63591),
 (39.34109, -76.63545),
 (39.34103, -76.63463),
 (39.34145, -76.63422),
 (39.33929, -76.63146),
 (39.33925, -76.62801),
 (39.33625, -76.62369),
 (39.33507, -76.62335),
 (39.33442, -76.62212),
 (39.33313, -76.62249),
 (39.33256, -76.62178),
 (39.33161, -76.62326)]

In [ ]: