Open dkbarn opened 4 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.
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.
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
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.