Skip to content

POST user fitbit auth

JeffMedeiros edited this page Dec 2, 2019 · 4 revisions

Description

Submit user data from the Fitbit account for use in data synchronization. This means that you obtained the access and refresh token through another client before submitting it here.

To find out how to get access token on Fitbit platform see here.

URL

POST https://localhost:5001/v1/users/{user_id}/fitbit/auth

Parameters

user_id: string (A 24-byte hex ID)

Request body

{
  "access_token": "eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0MzAzNDM3MzUsInNjb3BlcyI6Indwcm8gd2xvYyB3bnV0IHdzbGUgd3NldCB3aHIgd3dlaSB3YWN0IHdzb2MiLCJzdWIiOiJBQkNERUYiLCJhdWQiOiJJSktMTU4iLCJpc3MiOiJGaXRiaXQiLCJ0eXAiOiJhY2Nlc3NfdG9rZW4iLCJpYXQiOjE0MzAzNDAxMzV9.z0VHrIEzjsBnjiNMBey6wtu26yHTnSWz_qlqoEpUlpc",
  "refresh_token": "c643a63c072f0f05478e9d18b991db80ef6061e4f8e6c822d83fed53e5fafdd7"
}

Curl example

curl -X POST "https://localhost:5001/v1/users/5c86d00c2239a48ea20a0134/fitbit/auth" -H "accept: /" -H "Content-Type: application/json" -d "{"access_token":"eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0MzAzNDM3MzUsInNjb3BlcyI6Indwcm8gd2xvYyB3bnV0IHdzbGUgd3NldCB3aHIgd3dlaSB3YWN0IHdzb2MiLCJzdWIiOiJBQkNERUYiLCJhdWQiOiJJSktMTU4iLCJpc3MiOiJGaXRiaXQiLCJ0eXAiOiJhY2Nlc3NfdG9rZW4iLCJpYXQiOjE0MzAzNDAxMzV9.z0VHrIEzjsBnjiNMBey6wtu26yHTnSWz_qlqoEpUlpc","refresh_token":"c643a63c072f0f05478e9d18b991db80ef6061e4f8e6c822d83fed53e5fafdd7"}"

Response body

  • 204 Operation performed successfully. There is no data to be returned.

  • 400 Validation errors

    • Invalid JSON format

    • Invalid user id

    • Required fields (User Auth Data)

      • Pattern

        {
          "code": 400,
          "message": "Required fields were not provided...",
          "description": "User Auth Validation: {comma separated fields} required!"
        }
      • Example

        {
          "code": 400,
          "message": "Required fields were not provided...",
          "description": "User Auth Validation: access_token required!"
        }
        {
          "code": 400,
          "message": "Required fields were not provided...",
          "description": "Fitbit Auth Data Validation: access_token, refresh_token required!"
        }
    • User not registered on the platform

      • Pattern
        {
          "code": 400,
          "message": "The user does not have register on platform: {user_id}"
        }
    • Missing permissions for syncable resources

      • Pattern
        {
          "code": 400,
          "message": "The token must have permission for at least one of the features that are synced by the API.",
          "description": "The features that are mapped are: rwei (weight), ract (activity), rsle (sleep)."
        }
    • Access token expired

      • Pattern
        {
          "code": 400,
          "message": "Access token expired.",
          "description": "The access token {accessToken} has been expired and needs to be refreshed."
        }
    • Access token invalid

      • Pattern
        {
          "code": 400,
          "message": "Access token invalid.",
          "description": "The access token {accessToken} is invalid. Please make a new Fitbit Auth Data request and try again."
        }
    • Refresh token invalid

      • Pattern
        {
          "code": 400,
          "message": "Refresh token invalid.",
          "description": "The refresh token {refreshToken} is invalid. Please make a new Fitbit Auth Data request and try again."
        }
    • Data request limit for access token expired

      • Pattern
        {
          "code": 400,
          "message": "Data request limit for access token {accessToken} has expired.",
          "description": "Please wait a minimum of one hour and try make the operation again."
        }
    • Invalid Fitbit Client data

      • Pattern
        {
          "code": 400,
          "message": "Invalid Fitbit Client data.",
          "description": "The Fitbit Client credentials are invalid. The operation cannot be performed."
        }
    • Internal error

      • Pattern
        {
          "code": 400,
          "message": "A internal error occurs. Please, try again later."
        }
    • Internal error (unmapped)

      • Pattern
        {
          "code": 400,
          "message": "{ERROR_MESSAGE}"
        }
  • 500 Internal Server Error

  • 503 Fitbit service unavailable

    • Pattern
    {
      "code": 503,
      "message": "Could not connect with the Fitbit Server",
      "description": "Please try again later."
    }

Query Strings (Optional)

Query strings are used as follows: there must be a question mark following the URL and providing the parameters for the desired operation.