react-native-google-fit: GoogleFit.Authorize is hanging

I’ve installed & linked react-native-google-fit in order to allow my app to read Google Fit data. Specifically, I need to read the user’s heart rate data (it’s possible that I will need more than this at some stage).

I’ve created an OAuth 2.0 Client ID (although I just created it in the console and then downloaded a file - I haven’t actually put that file anywhere as none of the instructions I followed told me what to do with it).

In my app I have:

import React, { useEffect } from 'react'
import GoogleFit, { Scopes } from 'react-native-google-fit'

const Navigator = props => {

  useEffect(() => {
    GoogleFit.checkIsAuthorized().then(() => {

        if(!GoogleFit.isAuthorized) {
          const options = {
            scopes: [
              Scopes.FITNESS_ACTIVITY_READ,
              Scopes.FITNESS_BODY_READ
            ],
          }

          console.log("Attempting to authorize");

          GoogleFit.authorize(options)
            .then(authResult => {
              if (authResult.success) {
                console.log('Success')
                dispatch("AUTH_SUCCESS");
              } else {
                console.log('Denied')
                dispatch("AUTH_DENIED", authResult.message);
              }
            })
            .catch(() => {
              dispatch("AUTH_ERROR");
            })

        }else {
          console.log("Already authorized")
        }
      })
  },[])

When I run this, I get a screen which asks which Google account I wish to use to continue to my app; I select my account and then I just get a white box with the Google spinner in it. In the console I can see “Attempting to authorize”, but then nothing else happens.

Am I doing something wrong? I believe I have followed all steps in the instructions, but I must be missing something.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18

Most upvoted comments

@SharonGilmore Did you find a solution? I’m having the same problem