Capacitor Health Plugin unable to connect to Google Fit

Health plugin not able to connect to Google Fit. Initially it did work and we could fetch data from Google Fit. Later it started throwing the following error.

com.google.android.gms.common.api.ApiException: 4: The user must be signed in to make this API call

Could any one shed some light on what could be going wrong? Tried all solutions that members suggested on stackoverflow, without any luck.

Here is my Ionic info:

Ionic:

Ionic CLI : 6.20.8 (/Users/iosdev/.nvm/versions/node/v16.17.0/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 6.3.3
@angular-devkit/build-angular : 14.2.7
@angular-devkit/schematics : 14.2.7
@angular/cli : 14.2.7
@ionic/angular-toolkit : 6.1.0

Capacitor:

Capacitor CLI : 4.4.0
@capacitor/android : 4.4.0
@capacitor/core : 4.4.0
@capacitor/ios : 4.4.0

Utility:

cordova-res : 0.15.4
native-run : 1.7.1

System:

NodeJS : v16.17.0 (/Users/iosdev/.nvm/versions/node/v16.17.0/bin/node)
npm : 8.15.0
OS : macOS

Please help.

The error is saying that the user must be signed in to make the API call.

So looks like the user is not signed in into google fit or google services.

Are you testing on a real device or emulator?
If it’s an emulator, try in a real device.
If it’s a real device, open google fit app and see if the user is logged in.

Thank you for responding quickly.

I am using real device and am logged in. Still I get this error.

Regards

then it looks like a bug in the plugin or a misconfiguration, you should report an issue on the plugin repository

Ok. Will do so. Thank you.

I have raised the same issue with the author of the plugin.

Suggestions made did not work and am now on the lookout for an alternative. Is there another plugin that I can use to get the fitness data from Google Fit? I tried @perfood/capacitor-google-fit - npm but that plugin is not working with lonic 6.

Finally, we are now getting data from Google fit successfully in the app. I removed the isAuthorized call and added write permissions for couple of data types (though we are not writing anything from the app). Also, calling requestAuthorization every time a call is made to Google Fit API.