Vital Link is a client-side component your users will use to link their accounts with Vital and allow you to access their accounts via the Vital API.
Vital Link will handle credential validation and multi-factor authentication. Links works across modern browsers and mobile browsers via webviews.
The link flow starts when the user wants to connect a wearable device. An overview of the process can be found below. To start integrating Vital Link make sure you have your client_id and client_secret from your team dashboard.
1. Before initialising link token for a user, ensure you have generated a user_key for the specific user. Tyically this should be done when a user signs up to the service and is stored against the user in your database.
2. To launch link first issue a request to your servers and use your client_id, client_secret and user_key server side to generate a link_token.
3. Once you have your link_token, pass this into the link component to open the link for the user. The link_token is a short lived one time use token that is used to allow users to connect their wearable devices.
4. Use the OnSuccess, OnError, OnExit callbacks to react to different events client side.
Throughout the link process, link will send through messages based on the outcome of the link process. It is advised that you listen for these events and react acccordingly.
Use the link token to launch the link widget on your frontend. This will launch link widget straight into the login flow for the provider.
Depending on the platform you're integration link with, in the case of a successful login the Link component will send through a LINK_EVENT::SUCCESS or LINK_EVENT::FAILED depending on the outcome and then LINK_EVENT::CLOSE messages, either via web messaging or React Native Webview messaging.
We also support authenticating without Vital link. This is useful for users who don't want to use Vital link but still want to use the Vital API.
To authenticate without Vital link, you need to first generate alink_token for a specific user.
from vital import Client
client = Client(
token = client.Link.create(user_key)
oauth_url = client.Link.oauth_provider(link_token, "fitbit")
# redirect user to returned oauth_url
For OAuth Providers we return a oauth_url, that you can use to redirect users to in a webview. In a web browser on success the window would close and you are expected to check the connected providers on refocus to determine if the user has connected. In the case of mobile, the user receives a message to head back to the app. Our recommended way for mobile is to launch Link, as specified in the previous section, in a spefic state so you can receive the appropriate success messages in app.
The possible error codes that are returned are as follows:
401INVALID_REQUEST Link Token is Invalid
400MISSING_LINK_TOKEN Missing link token
400INVALID_PROVIDER Provider is not supported
400INVALID_USER_KEY User key is incorrect
400INVALID_CREDENTIALS Credentials for provider are incorrect