carecentive

Creating Google Fit Authorization Keys

To create your own authorization keys,

Open: https://console.cloud.google.com/

  • Create Project
  • Go to API & Services
    • Select Enabled API & Services → Enable Fitness API
  • Go to  API & Services
    • Select Create OAuth Consent Screen
      • Set App Name and User support email, developer email
      • Add Scopes (filter by keyword "fitness" and "read"), should be around 11 scopes ( Activity, Blood Glucose, Blood Pressure, Body, heart rate, temperature, location, nutrition, oxygen saturation, reproductive health, sleep)
      • Add Test users email address (Can only get data from these email addresses during development)
  • Select Credentials
    • Create credentials for OAuth Client ID
    • Authorized JS Origin -> Set Frontend/Backend url
    • Authorized redirect URL -> Set {Backend_baseUrl}/api/google-fit/auth-callback
  • Save Client ID and Client Secret in framework env file

Note:

User tokens created for each user when using the app can only be used for 10 days in development mode. Call /google-fit/disconnect endpoint to remove the old tokens and reconnect the user again for access.

CLIENT_ID = ...

CLIENT_SECRET = ...

REDIRECT_URI = {backend_base_url}/api/google-fit/auth-callback

Important Links: