8000 GitHub - jmn8718/coros-connect: Interact with COROS Api
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

jmn8718/coros-connect

Repository files navigation

coros-connect

Nodejs library to interact with COROS Api.

⚠️ It does NOT support browser as it uses node libraries.

⚠️ This repository is using a non-public API from COROS Training Hub that could break anytime.

This project is inspired by:

Instalation

npm install coros-connect

Usage

You can setup a configuration file on your project root called coros.config.json containing your email and password.

{
    "email": "my.email@example.com",
    "password": "MySecretPassword"
}

Or you can provide on the constructor or login command.

const coros = new CorosApi({
    email: "my.email@example.com",
    password: "MySecretPassword"
});

await coros.login("my.email@example.com","MySecretPassword");

Configuration

You can change some default configuration for the service to adapt to the coros website changes on the environment variable.

// check properties that can be update from the function types
coros.config({
    stsConfig: STSConfigs.EU
})

Reuse token

You can store the access token to a file so you can reuse the same token when creating a new client. This is useful as you can get a 429 response from COROS Api.

if (isDirectory(tokenFolder)) {
    coros.loadTokenByFile(tokenFolder);
} else {
    await coros.login();
    coros.exportTokenToFile(tokenFolder);
}

⚠️ The token can expire at any time, and COROS Api does not provide any information about it, and it can no be extracted from the token. So it is up to you to handle Unauthorized errors from COROS Api to get a new valid token.

Functionality

This library only supports the following:

  • Login on Coros and get an access token.
  • Get list of activities.
  • Get activity detail (and other data used on the Coros page for the activity).
  • Download an activity file.
  • Store and reuse access token.
  • Get profile
  • Upload activity file (fit and tcx) from other providers. (see upload notes on coros webapp).
  • Delete activity
  • Change configuration to adapt to different environment

TODO

  • Handle token expiration or invalid token. NOTE when you login using this package, it will automatically logout from the webapp (mobile app is ok). And when you login into the webapp, it will invalidate your token. So at the moment you have to handle this logic.

Example

You can find one example on here

License

MIT License

About

Interact with COROS Api

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0