CapacitorGoogleAuth icon indicating copy to clipboard operation
CapacitorGoogleAuth copied to clipboard

Avoid index out of bounds when the scopes array is empty on Android

Open panstromek opened this issue 2 years ago • 1 comments

The following code in the GoogleAuth class causes rather cryptic error when the scopes array is not provided or it's empty (NegativeArraySizeException).

https://github.com/CodetrixStudio/CapacitorGoogleAuth/blob/41ece7d6ff97643feb316df0113342a00d0d7717/android/src/main/java/com/codetrixstudio/capacitor/GoogleAuth/GoogleAuth.java#L70-L71

This happens when the developer provides empty array in config, but more importantly when the user provides no array (and assume some sensible default). In that case, the default array is used, which is empty (see line 70). It'd be nice to handle this case more gracefully, either by using some minimal default, or by giving a better error message to guide user to add scopes array.

panstromek avatar Mar 27 '23 10:03 panstromek

Had the same issue. After setting scopes: ['email', 'profile', 'openid'] in capacitor.config.ts it worked. These are the default scopes, but unfortunately we have the set them to get things working on android. On ios the scope handling is implemented much better.

seopei avatar Dec 14 '23 09:12 seopei