예제 #1
0
def get_strava_segments(box, activity_type='running'):
    response = None
    try:
        client = Client(access_token=private_values.STRAVA_ACCESS_TOKEN)
        response = client.explore_segments(box.bounds,
                                           activity_type=activity_type)
    except Exception:
        err = TokenException(
            "Invalid Strava token. Get a valid API key from Strava \
            and replace the ACCESS_TOKEN value in 'private_values.py'")
        raise err
    return response
예제 #2
0
def get_segments(lowerlat, lowerlong, upperlat, upperlong):
    # Accepts lower and upper bounds for a given coordinate area
    # Returns an object with route data, as parsed in application.py

    # Sets our key
    # As per: https://github.com/hozn/stravalib/blob/master/docs/usage/auth.rst#id5
    client = Client()
    token_response = client.refresh_access_token(
        client_id=30378,
        client_secret="67b60f8a8c450a837a2337fe9eb57515915d8fba",
        refresh_token="ed64949d3614e9a0574ecba44d5514de593c2c0b")
    key = token_response['access_token']

    # Sets the client and registers the token
    client = Client()
    client = Client(access_token=key)

    # Calls user data for the given range for running routes
    data = client.explore_segments([lowerlat, lowerlong, upperlat, upperlong],
                                   activity_type='running')

    # Returns the object
    return data