Welcome to pystrava’s documentation!¶
Contents:
Introduction¶
Transparent authentication for Strava API. This library has been inspired by spotifylib as it uses a very similar authentication flow.
The idea is to use all features and methods from stravalib but handling the authentication transparently just by providing all required details.
It’s currently written for Strava V3 API
Read more on USAGE.rst or Read the docs or check the code for substantial docstrings.
Features¶
- Same features as Stravalib’s library but with transparent authentication
- Renew’s the token transparently
Installation¶
At the command line:
$ pip install pystrava
Or, if you have virtualenvwrapper installed:
$ mkvirtualenv pystrava
$ pip install pystrava
Or, if you are using pipenv:
$ pipenv install pystrava
Usage¶
To use pystrava in a project:
First off you’ll have to create your application on your Strava profile.
Give it a name and as website you can just use http://localhost.local/callback
and in terms of Authorization Callback Domain, localhost.local
will suffice.
Once created, you should have a client_id
and a client_secret
.
You will also need to use a scope
to get a token that has access to the resources.
Read more about scopes here
Scopes can be appended by using a comma. Let’s assume we will use
activity:write,profile:read_all
as scope
.
$ pip install pystrava
from pystrava import Strava
import logging
import os
logging.basicConfig(level=logging.INFO)
strava = Strava(client_id=os.environ['CLIENT_ID'],
client_secret=os.environ['SECRET'],
callback=os.environ['CALLBACK_URL'],
scope=os.environ['SCOPE'],
email=os.environ['EMAIL'],
password=os.environ['PASSWORD'])
athlete = strava.get_athlete()
print(athlete)
To read more on what available methods and features stravalib
has, go to
this link.
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
Submit Feedback¶
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
Get Started!¶
Ready to contribute? Here’s how to set up pystrava for local development.
Clone your fork locally:
$ git clone https://github.com/wefner/pystrava
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your clone for local development:
$ mkvirtualenv pystrava $ cd pystrava/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
Commit your changes and push your branch to the server:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a merge request
pystrava¶
pystrava package¶
Submodules¶
pystrava.constants module¶
Main code for pystrava
pystrava.pystrava module¶
Main code for pystrava
-
class
pystrava.pystrava.
StravaAuthenticator
(client_id, client_secret, callback, scope, email, password)[source]¶ Bases:
object
This class handles Strava V3API OAuth authorization transparently.
More details can be found on https://developers.strava.com/docs/authentication
-
token
¶ Token namedtuple
Returns: namedtuple
-
pystrava.pystravaexceptions module¶
Custom exception code for pystrava
Credits¶
Development Lead¶
- Oriol Fabregas <fabregas.oriol@gmail.com>
Contributors¶
None yet. Why not be the first?
History¶
0.2.2 (2019-02-17)¶
- Fixed bug that gets redirects_uri
- Fixed bug about relative imports
0.2.1 (2019-02-12)¶
- Retrieve new access token if expired transparently
- Logging
- Docs
0.2.0 (2019-02-08)¶
- V3 API with refresh token
0.1.2 (2018-08-22)¶
- Parsing code query string with built-in methods
0.1.1 (2018-08-22)¶
- First release