OvalMoney / react-native-fitness

A React Native module to interact with Apple Healthkit and Google Fit.
MIT License
343 stars 68 forks source link

Unable to Authorize with Google Fit #21

Closed ShaharyarMaroof closed 4 years ago

ShaharyarMaroof commented 4 years ago

@scerelli I am trying to authorise the app to connect to google fit, but the Fitness.requestPermissions method always returns false. Is there some specific requirements for android? I saw a merge request #6 which was intended to allow connection even without Google Fit installed.

I am using react-native 0.60.6, lib version 0.2.4 and Android Q (API level 29) emulator. Any idea what could be wrong?

Francesco-Voto commented 4 years ago

Have you followed the section fro Android and create an OAuth 2.0 Client ID?

ShaharyarMaroof commented 4 years ago

Ah, I skipped that as it was in the manual section of the installation guide. Thanks, will look into this. Could you update the steps so that this is step is in the mandatory section of the guide?

ShaharyarMaroof commented 4 years ago

Hey @Francesco-Voto I created the key as mentioned in the Android section and since I used auto linking to link the package I did not have to manually link the lib in android. but I still cannot get authorised from the Google Fit API. Any suggestions?

Francesco-Voto commented 4 years ago

Hi @ShaharyarMaroof. Normally this kind of problems are some misconfiguration, since no info are inserted inside the codebase, but everything is handled via OAuth 2.0. Have you found some trouble to follow the guide at https://developers.google.com/fit/android/get-api-key?

ShaharyarMaroof commented 4 years ago

No I got the client key from the following the steps there. Now how will I integrate it with my Android project.

Won't we have to provide the google client ID somewhere in the app to connect to the Fitness API? As this lib has done? react-native-google-fit

Francesco-Voto commented 4 years ago

No this is not necessary. You just need to register your app in Google API console. You need also to call Fitness.requestPwermissions() first time you want to fetch the data.

Hope this will help. :)

ShaharyarMaroof commented 4 years ago

Thank you very much! :) (Y)

iitsuraj commented 4 years ago

For getting Oauth token, I followed (https://developers.google.com/fit/android/get-api-key), but when I ask for Fitness.requestPwermissions() it shows me to choose an account, and after selecting the account that screen disappears. And Fitness.isAuthorized return false value

rlems commented 4 years ago

For getting Oauth token, I followed (https://developers.google.com/fit/android/get-api-key), but when I ask for Fitness.requestPwermissions() it shows me to choose an account, and after selecting the account that screen disappears. And Fitness.isAuthorized return false value

@iitsuraj I'm experiencing the same issue, did you solve it?

Francesco-Voto commented 4 years ago

Usually this means a misconfiguration on OAuth 2.0 Client ID part. Please note for Debug ore Release you will use different SHA-1 as well as you need to create different Client ID if you change package name in your flavours

rlems commented 4 years ago

@Francesco-Voto You are right. I created the Client ID with the wrong debug.keystore, not the one provided with the React Native android project. Thank you for your help

GuleriaAshish commented 4 years ago

@ShaharyarMaroof are you able to get data without installing Google fit app on android?

ShaharyarMaroof commented 4 years ago

@GuleriaAshish , I don't remember as I moved to another library.

GuleriaAshish commented 4 years ago

@ShaharyarMaroof Which library, Please suggest.

shaharyarmaroof-polarr commented 4 years ago

@GuleriaAshish I used react-native-google-fit and rn-apple-healthkit

keiscool2468 commented 3 years ago

@rlems i already get the clientID from console.developers.google, where should i put it in. It did not mention in the Doc / Readme

Francesco-Voto commented 3 years ago

Nowhere. We are using OAuth 2.0 which relies on SHA and package name you put on console