As I was researching ways to integrate google login
to my app, I found several different ways:
- gapi (js library, deprecated), Google’s lib
- GIS(or GSI, Google Identity Services, new google SDK over gapi’s deprecation)
- Although this articles says Oauth2 implemention doesn’t affect
the deprecation in google js library, it seems to be pointing to
gapi’s repository - Third party libraries like next-auth, passport
- Hosted services like clerk and keycloak
With all these options at hands, I’m not very sure what would be the best choice to implement. No. 1(due to deprecated) and 5(for large customizable apps) are not my choices.
So, I’m wondering between GIS and Third party libs, owing to the confusion added atop by no. 3.
I’m wondering if these libraries internally had integrated Gapi, since it appears to be the oauth2.0 libraries that google had published and hence these libs might all be deprecated, or they’d upgrade to GIS in which case we don’t need these libraries?
What would be the rationale to choose between these two approaches? Whether to integrate a google made sdk/lib or a third party lib? And how would I know if the libs have updated to google’s new policies and gapi’s deprecation if they’d used it?
Edit: Also, wonder if these libraries would support the FedCM , which they state to be crucial after the third party cookie migration. It does seem looking at their source code, they use one lib called oauth4webapi for next/auth’s implementation( maybe others as well?) , yet I can’t seem to find anything mentioning FedCM in their docs. Similar stuff goes for passport-js
‘s oauth implementation
(I believe uses oauth , last published 2 years ago)
2
Answers
You can add
next-auth
only in the next project andpassport
for server authentication.clerk
andkinde
are good options that they can integrate with different auth providers, not only google.if you are only focusing google auth try this npm
@react-oauth/google
https://blog.logrocket.com/guide-adding-google-login-react-app/
With so many ways to integrate Google Login, it can be hard to choose. Here’s a brief guide:
Options:
Recommendations:
Example with next-auth
.env
:FedCM Support:
You will have to look at the repositories for next-auth and passport to see if or when they will be updated with FedCM support. They may take a bit of time to catch up with these changes.
Final Thoughts:
Hope this helps! Let me know if you have more questions.