Lorenzo Sandini
Lorenzo Sandini

Reputation: 117

Service account authentication for Google Fit API

I am quite a beginner and I am trying to write a standalone Node/JS application that will run on a raspberry pi, without any GUI.

I need to retrieve physical activity data from the Google Fitness REST API without using oauth2. I understand it can be done using a service account (?). So I activated the Fitness API, created oauth2 credentials and a service account. Created a key, that I am sending in my requests.

It works in the Google Docs API as in the example below, but when using the same apprach in the Google Fit API, I get the dreaded "error 403, insufficient credentials for this scope".

const auth = new docs.auth.GoogleAuth({
  keyFilename: 'MY_PRIVATE_KEY_HERE.json',
    // Scopes can be specified either as an array or as a single, space-delimited string.
  scopes: ['https://www.googleapis.com/auth/documents']
});

Does the Fit API require oauth2 authentification, or can a service acount be used ?

Thanks for your help,

Lorenzo

Upvotes: 3

Views: 374

Answers (1)

Related Questions