OvalMoney / react-native-fitness

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

OAuth consent screen showing wrong scopes #110

Open matinzd opened 2 years ago

matinzd commented 2 years ago

What is the problem?

I am trying to request these permissions:

const permissions: Permission[] = [
  {
    kind: Fitness.PermissionKinds.Steps,
    access: Fitness.PermissionAccesses.Read,
  },
  {
    kind: Fitness.PermissionKinds.Steps,
    access: Fitness.PermissionAccesses.Write,
  },
];

In this case, I need to see two permissions being granted on OAuth consent screen but if I include write permission, it always shows the following screenshot (Add to physical activity, so it means write not read):

Screenshot 2022-01-31 at 08 20 45

At this point, I tried to debug the code. As far as I debugged the code your code was fine and it was trying to build permissions according to the passed parameters through the react bridge. I found that FitnessOptions.builder.addDataType will always respect write permission for steps when I try to add also read permission. When you call getImpliedScopes() you can see that it only shows write scope as you can see in the attached screenshot:

Screenshot 2022-01-31 at 08 24 20

I would really appreciate it if you can fix the problem or help me with what's going wrong. I couldn't make it work to set both read and write scope even manually. I can only set read scope when I delete write access.