Login / Signup / SignIn with Google | OAuth2.0 | Using React and Express JS

Consulting Ninja June 1, 2023
Video Thumbnail
Consulting Ninja Logo

Consulting Ninja

View Channel

About

I am here to help as MANY others as possible with web development, software development, and consulting related obstacles and issues. I love development, technology, consulting and want to build a positive community of developers (front, back , middle, scripts, everyone!) and tech lovers helping each other and building each other up to become better! I hope to see you soon! My channel membership is live now you can check that out here: https://www.youtube.com/channel/UCwPrPv9eS7Xgfp_wi7uxt0g/join I hope to see you in one of my live stream meet ups! * FYI * No StackOverflow behavior will be tolerated in my channel. Give positive advice and clear feedback without talking down to those that don't know please.

Video Description

In this video I show how to setup your Google Developer Console to create an OAuth 2.0 consent screen and OAuth2 client id credentials to allow signing in with Google. I then show where to get the official google-auth-library for creating the initializing url and verifying tokens and extracting credentials. After that I show how to setup two Express Routes! One will build the url and pass it back to our React front-end. The other will receive the reply from Google and authenticate the code. I also show how to setup your React UI to ping our backend to retrieve the built URL and ping the GoogleAuth api using the redirect! As a bonus I also show how to use this access token to request the users information from the googleapis for userinfo! I hope that you find this helpful! Opening Tokens: https://youtu.be/ChUAcV0FdvM *There is additional information in here please read thoroughly such as the following* GoogleGSI is probably easier to implement check it out here: https://www.youtube.com/watch?v=rrSfsxFq0Dw My channel membership is live check it out here!: https://www.youtube.com/channel/UCwPrPv9eS7Xgfp_wi7uxt0g/join Membership perk video: https://youtu.be/FJgKifAThdU SvelteKit OAuth2 Video: https://youtu.be/4QwcC4hfqM0 PocketBase SvelteKit OAuth2 Video Here: https://youtu.be/Ig_RMc0GFw4 *Note* Save yourself the headache and do NOT attempt to have a different a separate origin URI from your redirect URI : i.e. do NOT initiate the request from origin URI localhost:5173 and then try to redirect in your backend back to Google. Google will not send the code it will send a Cross Site Request Forgery token that you need an additional package and TONS of work (they rotate the keys), to pull out and verify! OAuth2Client docs here: https://cloud.google.com/nodejs/docs/reference/google-auth-library/latest/google-auth-library/oauth2client Need help? visit https://www.consultingninja.tech Check out my channel @ConsultingNinja for more videos like these. Requirements when using Google Sign in Docs: https://developers.google.com/identity/branding-guidelines Source Code Available Here: https://github.com/consultingninja/oAuthReactExpress Vite Video Here: https://youtu.be/6sLoJuTmqiU Express Video Here: https://youtu.be/A2cdELhQHcU 00:00 - Intro 01:27 - Google Console Setup 06:00 - ENV Setup in Express 07:32 - Express Setup 20:44 - React Setup 25:52 - Wrap-Up *post release update* Googles Documentation is not great and you should play around a bit with opening different pieces of this to see what is inside. As an example: One place in Googles docs said that the field "id_token" only had 4 properties and none of them very useful. However after opening with const ticket = await oAuth2Client.verifyIdToken({idToken: id_token,audience:process.env.CLIENT_ID,}); I found this contained all user information as well. I have found other instances of Googles docs being misleading and or inaccurate. Just a note!

You May Also Like

Boost Your Web Dev Setup

AI-recommended products based on this video

Loading...
Dell S2722DC Monitor - 27-inch WQHD (2560x1440) 75Hz 4Ms Display, AMD FreeSync, Built in Speaker, USB Type-C/USB 3.2 Gen 1/HDMI Connectivity, Height/Pivot/Swivel/Tilt Adjustability - Platinum Silver
Amazon's Choice

Dell S2722DC Monitor - 27-inch WQHD (2560x1440) 75Hz 4Ms Display, AMD FreeSync, Built in Speaker, USB Type-C/USB 3.2 Gen 1/HDMI Connectivity, Height/Pivot/Swivel/Tilt Adjustability - Platinum Silver

(4,001)
$299.99
FREE delivery Sun, Aug 24
200+ bought in past month
Loading...
Dell 27 Plus 4K Monitor - S2725QS - 27-inch 4K (3840 x 2160) 120Hz 16:9 Display, IPS Panel, AMD FreeSync Premium, sRGB 99%, Integrated Speakers, 1500:1 Contrast Ratio, Comfortview Plus - Ash White

Dell 27 Plus 4K Monitor - S2725QS - 27-inch 4K (3840 x 2160) 120Hz 16:9 Display, IPS Panel, AMD FreeSync Premium, sRGB 99%, Integrated Speakers, 1500:1 Contrast Ratio, Comfortview Plus - Ash White

(13)
$309.99$297.59
FREE delivery Tue, Oct 7
200+ bought in past month
Loading...
StanbyME LG 27-Inch Class Smart Portable Touch Screen Monitor 27ART10AKPL. Built-in 3 Hour Battery, Full Swivel Rotation, Rollable. LG Stanbyme, Standbyme, Stand by me.

StanbyME LG 27-Inch Class Smart Portable Touch Screen Monitor 27ART10AKPL. Built-in 3 Hour Battery, Full Swivel Rotation, Rollable. LG Stanbyme, Standbyme, Stand by me.

(75)
$1,097.98
FREE delivery Sun, Aug 10
50+ bought in past month
Loading...
KOORUI 27-inch IPS WQHD (2560 x 1440) Computer Monitor, 100Hz, AdaptiveSync, HDMI, DP Port, Tilt, VESA Mountable, Eye Care, 2K PC Monitor for Gaming and Working, Black, E2721F

KOORUI 27-inch IPS WQHD (2560 x 1440) Computer Monitor, 100Hz, AdaptiveSync, HDMI, DP Port, Tilt, VESA Mountable, Eye Care, 2K PC Monitor for Gaming and Working, Black, E2721F

(3,892)
$169.99$152.99
FREE delivery Sun, Aug 10
50+ bought in past month
Loading...
FOYTOKI 2 Sets Rechargeable Hand Warmers Portable with Temperature Levels Ergonomic Design for School Office

FOYTOKI 2 Sets Rechargeable Hand Warmers Portable with Temperature Levels Ergonomic Design for School Office

(0)
$14.15
FREE delivery Jul 2 - 22
Loading...
Zewwen Laptop Stand for Desk, Ergonomic Adjustable Foldable Computer Stand with Heat-Vent, Aluminium Alloy Laptop Riser Compatible with MacBook Air, Pro, Dell XPS, Samsung, 10”-16"

Zewwen Laptop Stand for Desk, Ergonomic Adjustable Foldable Computer Stand with Heat-Vent, Aluminium Alloy Laptop Riser Compatible with MacBook Air, Pro, Dell XPS, Samsung, 10”-16"

(1,679)
$28.49
FREE delivery Sat, Jun 14 on your first order
500+ bought in past month
Loading...
Zewwen Laptop Stand for Desk, Ergonomic Adjustable Foldable Computer Stand with Heat-Vent, Aluminium Alloy Laptop Riser Compatible with MacBook Air, Pro, Dell XPS, Samsung, 10”-16"

Zewwen Laptop Stand for Desk, Ergonomic Adjustable Foldable Computer Stand with Heat-Vent, Aluminium Alloy Laptop Riser Compatible with MacBook Air, Pro, Dell XPS, Samsung, 10”-16"

(1,679)
$29.44
FREE delivery Sat, Jun 14 on your first order
300+ bought in past month
Loading...
eXtremeRate ThumbsGear Interchangeable Thumbstick for Xbox Controller - Improve Comfort - Orange 3 Height Domed & Concave Grips Ergonomic Adjustable Joystick for Xbox Core, for Xbox One S/X/Elite

eXtremeRate ThumbsGear Interchangeable Thumbstick for Xbox Controller - Improve Comfort - Orange 3 Height Domed & Concave Grips Ergonomic Adjustable Joystick for Xbox Core, for Xbox One S/X/Elite

(680)
$19.99
FREE delivery Sun, Aug 24 on your first order
Loading...
Monster N-Lite 211 Wireless Earbuds, Bluetooth 6.0 Stereo Headphones with Noise-Cancelling Mic and LED Display, Built-in Mic for Clear Calls, Waterproof Design for Sports

Monster N-Lite 211 Wireless Earbuds, Bluetooth 6.0 Stereo Headphones with Noise-Cancelling Mic and LED Display, Built-in Mic for Clear Calls, Waterproof Design for Sports

(8)
$39.99
FREE delivery Tue, Nov 4
Loading...
Monster N-Lite 211 Wireless Earbuds, Bluetooth 6.0 Stereo Headphones with Powerful Bass, Built-in Noise-Cancelling Mic for Clear Calls, LED Display, 36H Playtime, IPX5 Waterproof Design for Sports

Monster N-Lite 211 Wireless Earbuds, Bluetooth 6.0 Stereo Headphones with Powerful Bass, Built-in Noise-Cancelling Mic for Clear Calls, LED Display, 36H Playtime, IPX5 Waterproof Design for Sports

(40)
$39.99
FREE delivery Thu, Nov 13
Loading...
Logitech G203 Wired Gaming Mouse, 8,000 DPI, Rainbow Optical Effect LIGHTSYNC RGB, 6 Programmable Buttons, On-Board Memory, Screen Mapping, PC/Mac Computer and Laptop Compatible - Black
Best Seller

Logitech G203 Wired Gaming Mouse, 8,000 DPI, Rainbow Optical Effect LIGHTSYNC RGB, 6 Programmable Buttons, On-Board Memory, Screen Mapping, PC/Mac Computer and Laptop Compatible - Black

(17,871)
$27.98$22.38
FREE delivery Tue, Oct 14 on your first order
500+ bought in past month
Loading...
Lenovo M210 RGB Wired Gaming Mouse for PC, Laptop, Computer with Windows & Chrome OS - 3 Zone RGB, 8000 DPI Adjustable Sensor, 7 Programmable Buttons – Palm Grip Mouse for Gamers (Black)

Lenovo M210 RGB Wired Gaming Mouse for PC, Laptop, Computer with Windows & Chrome OS - 3 Zone RGB, 8000 DPI Adjustable Sensor, 7 Programmable Buttons – Palm Grip Mouse for Gamers (Black)

(52)
$26.62
FREE delivery Tue, Jun 17 on your first order
Loading...
Laptop Stand for Desk, Adjustable Laptop Riser ABS+Silicone Foldable Portable Laptop Holder, Ventilated Cooling Notebook Stand for 10-15.6” Laptops,Tablet-Black

Laptop Stand for Desk, Adjustable Laptop Riser ABS+Silicone Foldable Portable Laptop Holder, Ventilated Cooling Notebook Stand for 10-15.6” Laptops,Tablet-Black

(11,679)
$14.99
FREE delivery Sat, Jun 14 on your first order
500+ bought in past month
Loading...
Zewwen Laptop Stand for Desk, Ergonomic Adjustable Foldable Computer Stand with Heat-Vent, Aluminium Alloy Laptop Riser Compatible with MacBook Air, Pro, Dell XPS, Samsung, 10”-16"

Zewwen Laptop Stand for Desk, Ergonomic Adjustable Foldable Computer Stand with Heat-Vent, Aluminium Alloy Laptop Riser Compatible with MacBook Air, Pro, Dell XPS, Samsung, 10”-16"

(1,679)
$28.49
FREE delivery Sat, Jun 14 on your first order
500+ bought in past month
Loading...
Zewwen Laptop Stand for Desk, Ergonomic Adjustable Foldable Computer Stand with Heat-Vent, Aluminium Alloy Laptop Riser Compatible with MacBook Air, Pro, Dell XPS, Samsung, 10”-16"

Zewwen Laptop Stand for Desk, Ergonomic Adjustable Foldable Computer Stand with Heat-Vent, Aluminium Alloy Laptop Riser Compatible with MacBook Air, Pro, Dell XPS, Samsung, 10”-16"

(1,679)
$29.44
FREE delivery Sat, Jun 14 on your first order
300+ bought in past month
Loading...
VIVO 81cm Desk Converter, K Series, Height Adjustable Sit to Stand Riser, Dual Monitor and Laptop Workstation with Wide Keyboard Tray, Black, DESK-V000K

VIVO 81cm Desk Converter, K Series, Height Adjustable Sit to Stand Riser, Dual Monitor and Laptop Workstation with Wide Keyboard Tray, Black, DESK-V000K

(13,797)
$139.99$103.20
FREE delivery Thu, Jun 26
200+ bought in past month