Saw some questions in the forum about authenticating into Node-RED using Google OAuth, but couldn't find a working example.
So here is the code after I got it working with passport-google-oauth.
Does this need any settings in Google API's? Also, does it need a callback URL that is actually accessible by Google? (quite a lot of these API's don't).
Yes, this required generating a ClientId and ClientSecret at https://console.developers.google.com/apis/credentials.
The "Authorized redirect URIs" I entered there must match the callbackURL that I set in the strategy options in Node-RED.
Adding screenshots of the admin settings below.
Regarding whether the callback really needs to be accessible by Google, I'm afraid I don't know.
My Node-RED instance is publicly available but I don't know if this is a must.
I just implemented this and it works great. A couple of things I noticed:
you need to install passport-google-oauth with npm or you'll get a settings error: npm install passport-google-oauth
I believe a comma is missing after the last close bracket, e.g. },
In the google credentials settings, you have to add the redirect url as https://your-node-red-instance.com/auth/strategy/callback
MOST IMPORTANT: This allows ANYONE with a google account to sign in. I'm able to restrict it to my organization / workspace account by leaving it as "internal", but just please be aware!
You can address #4 by changing out the section here: