GoogleSignIn requestPermissions onActivityResult 0 with Google Fitness steps/distance Scope
I have tried recreating the firebase project, switching SHA1, and moving things around but nothing seems to be working... please help
Code is as following:
val fitnessOptions = FitnessOptions.builder()
.addDataType(DataType.TYPE_DISTANCE_DELTA, FitnessOptions.ACCESS_WRITE)
.addDataType(DataType.TYPE_STEP_COUNT_DELTA, FitnessOptions.ACCESS_WRITE)
.addDataType(DataType.TYPE_STEP_COUNT_CUMULATIVE, FitnessOptions.ACCESS_WRITE)
.build()
val account = GoogleSignIn.getAccountForExtension(activity, fitnessOptions)
return if (GoogleSignIn.hasPermissions(account, fitnessOptions)) {
PrefsHelper.prefs(activity)[PrefsHelper.GOOGLE_FIT_PERMISSION_STATUS] = true
true
} else {
GoogleSignIn.requestPermissions(fragment, Constant.GOOGLE_FIT_SIGN_IN_PERMISSION, account, fitnessOptions)
false
}
and on main activity:
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == Activity.RESULT_OK) {
when (requestCode) {
Constant.GOOGLE_FIT_SIGN_IN_PERMISSION -> {
googleFitToggle.isChecked = permissionsUseCase.confirmGoogleFitSignIn()
}
}
} else if (resultCode == Activity.RESULT_CANCELED) {
when (requestCode) {
Constant.GOOGLE_FIT_SIGN_IN_PERMISSION -> {
PrefsHelper.prefs(requireContext())[PrefsHelper.GOOGLE_FIT_PERMISSION_STATUS] = false
}
}
}
}
finally figured it out, apparently they added a new section "OAuth consent screen" in the google developer console to allow testing to specified users of google account and to provide specialized scope messages for different types of health info permission in google's own dialog when in production (and no access otherwise)
Thanks to this Guide:
http://smartandroidians.blogspot.com/2020/03/configuring-google-fitness-api-in.html