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. Authorize access
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 the URL given by get_authorization_url()
to authorize the account access.
Sample code:
from accesslink import AccessLink
accesslink = AccessLink(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
redirect_url=REDIRECT_URL)
# Navigate the user to the following URL so they can complete the authorization form.
# Code for this will vary by application.
auth_url = accesslink.get_authorization_url()
3. Link user
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
4. 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.5.tar.gz
.
File metadata
- Download URL: polar_accesslink-0.0.5.tar.gz
- Upload date:
- Size: 7.1 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 | b8133960f4880b47db67dc5d4e914c51b9e9446afaebec8348d681a7631aed1a |
|
MD5 | 1b3dd8b1a56304ce216657dfd8d41686 |
|
BLAKE2b-256 | 24bda928f8601c5c0eedc961d28ca64fc47ec7f7fba7d47119852199dabc5fe5 |
File details
Details for the file polar_accesslink-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: polar_accesslink-0.0.5-py3-none-any.whl
- Upload date:
- Size: 11.7 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 | 81d738f282e44be47eb088f66183863cd9440511dd4237784eff27dbd5fd29ff |
|
MD5 | 6a2f37b3daf53d2e7ec208b28c39c5d4 |
|
BLAKE2b-256 | 214ee939cb52b307c231ca316d6aceb92fae877f257b004efd522e6daf5bf364 |