Python wrapper for Polar Open AccessLink API.
Project description
Polar AccessLink API Client
Library to enable access to Polar training data through the Polar Open AccessLink API. This library is a forked and packaged version of the offical Polar AccessLink example client.
- Free software: MIT license
Prerequisites
- Polar Flow account
Getting Started
1. Create new API client
Navigate to https://admin.polaraccesslink.com. Log in with your Polar Flow account and create a new client using an appropriate OAuth2 callback URL for your application. Note the client ID and client secret -- you will need these later.
2. Link user
User account needs to be linked to client application before client can get any user data. User is asked for authorization in Polar Flow, and user is redirected back to application callback url with authorization code once user has accepted the request. Navigate to 'https://flow.polar.com/oauth2/authorization?response_type=code&client_id=CLIENT_ID' to link your user account. Your application should handle the callback request appropriately, storing the user ID and access token which will be necessary for later API calls. The user must first be registered with the given access token before additional API calls can be made.
Sample code:
from accesslink import AccessLink
accesslink = AccessLink(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
redirect_url=REDIRECT_URL)
authorization_code = request.args.get("code")
token_response = accesslink.get_access_token(authorization_code)
USER_ID = token_response["x_user_id"]
ACCESS_TOKEN = token_response["access_token"]
try:
accesslink.users.register(access_token=ACCESS_TOKEN)
except requests.exceptions.HTTPError as err:
# Error 409 Conflict means that the user has already been registered for this client.
# For most applications, that error can be ignored.
if err.response.status_code != 409:
raise err
3. Access API data
Once user has linked their user account to client application and synchronizes data from Polar device to Polar Flow, application is able to load data.
Sample code:
from accesslink import AccessLink
accesslink = AccessLink(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET)
user_info = accesslink.users.get_information(user_id=USER_ID,
access_token=ACCESS_TOKEN)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file polar_accesslink-0.0.1.tar.gz
.
File metadata
- Download URL: polar_accesslink-0.0.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d400f12a5f90b5b951faab683e194e86fb4c4873289b09cc39ec3bebfd10707 |
|
MD5 | 21335f23f23dbc862a8251982521ea9d |
|
BLAKE2b-256 | 74ab1c719544b640da2ab594767ea1a997e0771d92fd7fdb7b80e3803b851edf |
File details
Details for the file polar_accesslink-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: polar_accesslink-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4125e053a06d1ea856e8ecd8e936f188947d3d21669e92ff1764ef632ca6796e |
|
MD5 | 22d99da92ad9b743b476a292d3289aeb |
|
BLAKE2b-256 | 1a3f69d2985b5d54980009a08e281669598660f7d3a108062df6019bf2f9f732 |