sladkovm / stravaio

Python client for Strava API with a focus on fluent data handling
MIT License
71 stars 30 forks source link

Can't change the scope for oauth2 authentication #11

Open dkbarn opened 3 years ago

dkbarn commented 3 years ago

When using stravaio_oauth2 to authenticate an application, there is no way to change the access scope to allow for write access to anything. The scope has been hardcoded to read access only: https://github.com/sladkovm/stravaio/blob/master/stravaio.py#L366

The scope should be exposed as an argument to the public strava_oauth2 function.

dkbarn commented 3 years ago

Ok I think I misunderstood what this library was. I thought it was a Python wrapper around the complete Strava REST API, but apparently it is limited to only reading information from Strava and cannot do any writing/uploading to Strava.

The name StravaIO is misleading, maybe it should be renamed to StravaO.

Tim-Haarman commented 3 years ago

I have the same problem, the lib seems great but I can't use it for my own data because I have all my activities set on private and can't change the hardcoded scope which only allows for retrieving public activities. It sadly seems like this project isn't maintained anymore, but if it gets picked up again it would be nice to have the scope as a parameter.

nickswalker commented 1 year ago

If you just need read access to private activities, you can monkey patch in the read_all scope:

import stravaio
# Before you do anything with stravaio
def _request_strava_authorize(client_id, port):
    import webbrowser
    import urllib
    params_oauth = {
        "client_id": client_id,
        "response_type": "code",
        "redirect_uri": f"http://localhost:{port}/authorization_successful",
        "scope": "read,profile:read_all,activity:read_all",
        "state": 'https://github.com/sladkovm/strava-http',
        "approval_prompt": "force"
    }
    values_url = urllib.parse.urlencode(params_oauth)
    base_url = 'https://www.strava.com/oauth/authorize'
    rv = base_url + '?' + values_url
    webbrowser.get().open(rv)
    return None

stravaio._request_strava_authorize = _request_strava_authorize