Addressing Google's comment:
react-native-google-signin currently uses GoogleAuthUtil.getToken by default, which Google recommends only in specific cases such as "if you need an access token directly, e.g. protocols like SASL XOAUTH2."
There are 3 other flows that might be more suitable and secure for most uses cases:
- To authorize and use REST API in you Android app, check out: Authorizing with Google for REST APIs
- To authenticate with a backend server, use Google Sign-In API to retrieve an ID token
- To enable server-side access, use Google Sign-In API to retrieve an auth code
The only change required by the id token and auth code flows seem to be in the GoogleSignInOptions call, so maybe we can add an option in the JS call to specify a specific flow?
(Following up #595)
quick comment: we already support id token and auth code, the only problem is that the deprecated GoogleAuthUtil.getToken is executed for each login, for parity with ios. It would likely make sense to remove that call from login procedure and leave it available through https://github.com/react-native-community/react-native-google-signin#gettokens
PRs welcome
I see, so basically implementing that.
I didn't realize id token and auth code were already supported, thank you!
Also just to clear that up, the token methods using accountName strings are deprecated, but the ones using accounts are not.
@hery would you be willing to open a PR for this? Thanks.
@vonovak Sure I can do that. One last thing to clear up before I dig in, should we either
GoogleAuthUtil.getToken methods with the non-deprecated methods?GoogleAuthUtil.getToken from the login procedure?Thanks!
thanks!
@hery do you plan to take a look at this? If you haven't started, I might have time to do it this weekend.
Hi @vonovak, sorry about the lack of activity, we ended up doing the update without GoogleAuthUtil migration and I got busy with other features. I'll let you know when I can tackle this.