Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Fit REST API returns empty Data Sources

I sent a request to the Fit REST API to get Data Sources.

I have received the results at the prompt. But the value of dataSource in the JSON is empty as below.

{
"dataSource": []
}

 

What I did before I received this result

I sent the request with curl. Here are the prompts I entered:

curl \
> -H "Content-Type: application/json" \
> -H "Authorization: Bearer ya29.a0Ael9sCMf-tgDVCIN-DOnNe1FuCX9KjUlU9mP-_CSPS2GS7hGM7mOOhc1OuwcRxJASoS0_8h3C3BziCqON-TZZ5GAKnyiM3DsQhhsP8sFihNT52VnCsVMebICf1U0UzmttHCR7TyFyx30gVsOzZg0_Pt4IBPZQQaCgYKAQcSARMSFQF4udJhXOIhNiY2bOzgZWWevI96vw0165" \
> -v https://www.googleapis.com/fitness/v1/users/me/dataSources

 

curl's verbose option does not show any problematic errors. 

The characters "HTTP/2 200" are seen in the prompt, so I think the HTTP response code is normal.

 

Also, I performed OAuth authorization according to the following site.

(Before sending the curl request, of course.)

Using OAuth 2.0 for Web Server Applications 

I got the access token successfully.
Only one scope specified: fitness.heart_rate.read

 

description of my environment

 

  • I ran curl from Amazon Linux 2.
    I'm connecting to an AWS EC2 instance via SSH from my local PC.

 

  • Google Fit data appears to be successfully registered in the Fit app on Pixel6a.
  • Android version 12   /  Windows 10 Pro (my local PC)

 

Solved Solved
0 1 1,471
1 ACCEPTED SOLUTION

I solved my problem of this question on my own.

I post here my solution.

 

I'm glad if someone in the same problem see this:

 

I haven't set the scope "fitness.heart_rate.read" on the application side.

I mean on my GCP Console. So I added the scope at OAuth consent menu.

 

It was not enough to include the scope as a request parameter in the OAuth URL.

Because the user-allowed scopes and the application-configured scopes did not match.

View solution in original post

1 REPLY 1

I solved my problem of this question on my own.

I post here my solution.

 

I'm glad if someone in the same problem see this:

 

I haven't set the scope "fitness.heart_rate.read" on the application side.

I mean on my GCP Console. So I added the scope at OAuth consent menu.

 

It was not enough to include the scope as a request parameter in the OAuth URL.

Because the user-allowed scopes and the application-configured scopes did not match.

Top Labels in this Space