How To Integrate Google Login in React! [Easy] | Add Auth To Your React Project

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.ย. 2024
  • Are you looking to integrate google login in your react website. In this video, i will show you how to add google sign in Auth to your react project easily!
    💖Be A Patron(Support On Monthly Basis)-
    ☑ / codewithmasood
    Get Source Code and Other Perks!
    👋Connect With Me:
    ▶Facebook - / official.codewithmasood
    ▶Instagram - / codewithmasood.official
    ▶Blog - / codewithmasood
    ▶Pinterest - / codewithmasood
    📙Must Read Books That Will Transform Your Thinking-
    ▶Psychology of Money: amzn.to/3jqvhyp
    ▶How to Win Friends and Influence People: amzn.to/3GifLh7
    ▶Power of Habit: amzn.to/3FRszcW
    ▶Ego is the Enemy: amzn.to/3GmZA26
    ▶Cracking the Coding Interview: amzn.to/3C2bYBW
    ▶Introduction to Algorithms: amzn.to/3jzkt1f
    ▶Cryptography and network security: amzn.to/3WQrol3
    #react
    #tutorial
    #codewithmasood
    #programming
    #coding
    DISCLAIMER: Some of the links in the description above are affiliate links, which means that if you click on one of the links and make a purchase, I will receive a small commission. This helps support the channel and allows me to continue to make videos like this. Thank you for your support!

ความคิดเห็น • 80

  • @rimo8833
    @rimo8833 หลายเดือนก่อน +2

    I spent 2 days trying to figure out how to get it done!! Bro u are Amazing. Thank u from the depth of my heart!! I was stuck with how to get data from acess token actually.

  • @420loaf69
    @420loaf69 7 หลายเดือนก่อน +2

    Masood thank you for this amazing tutorial. I was stuck trying to implement this on my own and you accomplished more in 5 minutes than I did all day. Giving me hope for my first custom React app. Thank you 🙏

  • @hkimiamin3084
    @hkimiamin3084 10 วันที่ผ่านมา

    thank you it worked perfectly !

  • @yurikruk
    @yurikruk 8 หลายเดือนก่อน +3

    awesome lesson, thank you

  • @ntokozomngadi573
    @ntokozomngadi573 3 วันที่ผ่านมา

    Thank you

  • @user-xe4vu8st5e
    @user-xe4vu8st5e หลายเดือนก่อน +1

    thank you brother

  • @vinoddeep613
    @vinoddeep613 5 หลายเดือนก่อน +2

    Thank you ,
    Cross-Origin-Opener-Policy policy would block the window.closed call. how to fix this error, when google popup opens

  • @kenmiyagi5672
    @kenmiyagi5672 ปีที่แล้ว +1

    Thank you so much man. You made my day.

  • @Karadiofficial
    @Karadiofficial 7 หลายเดือนก่อน +10

    blank page comes

    • @Karadiofficial
      @Karadiofficial 7 หลายเดือนก่อน

      Fixed it by setting only localhost

    • @teslagaming3549
      @teslagaming3549 2 หลายเดือนก่อน

      Same if you find solution tell me

    • @Karadiofficial
      @Karadiofficial 2 หลายเดือนก่อน

      I watched another video and did it .

    • @vpnuser5399
      @vpnuser5399 หลายเดือนก่อน

      Send that video ​@@Karadiofficial

    • @chuchutv111
      @chuchutv111 8 วันที่ผ่านมา

      how plss tel which video?​@@Karadiofficial

  • @LeJo-vi1gl
    @LeJo-vi1gl 10 หลายเดือนก่อน +2

    Thanks a lot, very helpful 😁

  • @mindzkonnectedgaurav
    @mindzkonnectedgaurav 10 หลายเดือนก่อน +1

    thanks bro , saved my hours .

  • @gideonamweich7271
    @gideonamweich7271 6 หลายเดือนก่อน +5

    Cross-Origin-Opener-Policy policy would block the window.closed call. how to fix this error, when google popup opens

    • @akashrajawat3676
      @akashrajawat3676 2 หลายเดือนก่อน

      have you found the solution yet?

  • @NguyenLinh-cg6zm
    @NguyenLinh-cg6zm 14 วันที่ผ่านมา

    I implement like the video, but the popup show on right-center not center-center, do you know why?

  • @ayoubelgueddari3767
    @ayoubelgueddari3767 11 หลายเดือนก่อน +1

    great job man

  • @julienheng3880
    @julienheng3880 10 หลายเดือนก่อน +2

    Please do the facebook login next! thank you for the tutorials!

    • @CodeWithMasood
      @CodeWithMasood  10 หลายเดือนก่อน +2

      Okay! Will upload soon

  • @user-jj4mi4ok3s
    @user-jj4mi4ok3s 27 วันที่ผ่านมา

    thanks its working

  • @MiguelSilva-ur9xd
    @MiguelSilva-ur9xd 8 หลายเดือนก่อน +1

    thk man, u save me

  • @chiennguyen2599
    @chiennguyen2599 10 หลายเดือนก่อน +3

    Why doesn't Mine return Access_token?

  • @Ezep02
    @Ezep02 8 หลายเดือนก่อน +2

    what happen if a i'd like logout?

  • @mark-aballe
    @mark-aballe 5 หลายเดือนก่อน

    I followed your steps and it's working, thank you! But there is a error "Cross-Origin-Opener-Policy policy would block the window.closed call." How to fix this?

  • @Captainzee4488
    @Captainzee4488 ปีที่แล้ว

    Welldone champ!

  • @nguyenvannghi1722
    @nguyenvannghi1722 หลายเดือนก่อน

    hay. i from vietnam

  • @zen_bean9265
    @zen_bean9265 8 หลายเดือนก่อน +2

    hey can u do a tutorial about how to do it in a server? cus setting the google api key for the public to view is dangerous right

    • @CodeWithMasood
      @CodeWithMasood  8 หลายเดือนก่อน +1

      Okay! Will make it soon!

    • @zancrow_gaming
      @zancrow_gaming 7 หลายเดือนก่อน +1

      This method is the easiest. I want to update my API for authentication with node express. But it's alot harder doing it on the backend. Since you worried about security on the client side, I can help you with that. In your react app, at the root level, create a new file ".env" then pass in environment variables e. GOOGLE_CLIENT_ID = the id from Google.
      The go to you registration page and to get the Google client id. If it's vite, do import.meta.VITE_GOOGLE_CLIENT_ID if vanilla react, replace the VITE with REACT. You welcome your keys are safe. I personally will prefer all my site logic on the server, I just think it's better to separate it. But the above method I gave you is quite secure. When you host it, pass the .env key and value pair on the site you hosted it

  • @The_Builder_Bobs
    @The_Builder_Bobs 8 หลายเดือนก่อน +1

    bro what is this error an error occurred the current origin is not registered with the google oauth client

  • @ayoubfatmi4739
    @ayoubfatmi4739 9 หลายเดือนก่อน +1

    thank you

  • @hirenhadiya1706
    @hirenhadiya1706 5 หลายเดือนก่อน

    thanks bro it is very halpful for me to impliment google login

    • @CodeWithMasood
      @CodeWithMasood  5 หลายเดือนก่อน +1

      Glad to hear that!

  • @AnasKhan-wf3sn
    @AnasKhan-wf3sn 8 หลายเดือนก่อน +2

    and also i got only white screen when I click on the button

    • @CodeWithMasood
      @CodeWithMasood  8 หลายเดือนก่อน +2

      Watch the video again carefully bro and you will get it done. Moreover, you can message me on Patreon or Instagram for guide

  • @balaji111
    @balaji111 หลายเดือนก่อน

    how to resolve cors origin opener policy error

  • @BoaRifa
    @BoaRifa 5 หลายเดือนก่อน

    Thank you 🇧🇷 🤝 🇮🇳

  • @BalajiBoddepalli-nj2ec
    @BalajiBoddepalli-nj2ec 3 หลายเดือนก่อน

    Hello brother i have a doubt, this code is used only for the test users that we've provided. how to make it work for every user

  • @420loaf69
    @420loaf69 6 หลายเดือนก่อน

    Do you recommend using this method with next.js framework in place of next-auth package?

  • @HazwaniAzlan
    @HazwaniAzlan 4 หลายเดือนก่อน

    hi, why show error when you try to login? I mean cross-origin-opener-policy, how to prevent it?

  • @MiriamHorlik
    @MiriamHorlik 2 หลายเดือนก่อน

    FYI react-google-login library is deprecated

  • @codehobby567
    @codehobby567 4 หลายเดือนก่อน

    actually it is not updating the sign the as

  • @maximvoicu4155
    @maximvoicu4155 2 หลายเดือนก่อน

    any updates on COOP error ?

  • @kueifengtung
    @kueifengtung 7 หลายเดือนก่อน +1

    jwt_decode library is out of date and also returns an error that the google access token returned by google is not the right format? bad guide

    • @ThePerrocraft
      @ThePerrocraft 6 หลายเดือนก่อน

      You should be more carefull to say "bad guide".
      Package.json
      External libraries may be updated at any time
      In this case you can fix it with
      ...
      "jwt-decode": "^4.0.0",
      "@react-oauth/google": "^0.12.1",
      ...
      It´s obvious that if the library is "out of date" you MUST update it..

    • @tylerdurden4563
      @tylerdurden4563 4 หลายเดือนก่อน

      @@ThePerrocraft The guide does not work as intended and promised by the creator. So, it is a bad guide. If the package is updated, the creator should update the video/guide. If not, bad guide

    • @ThePerrocraft
      @ThePerrocraft 4 หลายเดือนก่อน

      @@tylerdurden4563 Update the video at every library update?. u serious?
      No way.
      A programmer must think about this things.

  • @2929_SowmikDey
    @2929_SowmikDey 29 วันที่ผ่านมา

    But how will I use it in backend??
    Pls explain I've stuck

    • @MrAlao675
      @MrAlao675 27 วันที่ผ่านมา

      If you use backend like 'node', just call your api endpoint inside the 'onSuccess' callback function, pass 'credentialResponse.credential' as payload, use jwt-decode to get the actual json data....!
      if you are like me, using nextjs, just use server action, pass 'credentialResponse.credential' as payload, use jwt-decode to get the actual json data....!
      you can save the data to your database and register user session.

    • @GeekSlider
      @GeekSlider 8 วันที่ผ่านมา

      There is a bug in library it always asks for consent popup ​@@MrAlao675

  • @IgorStorozhuk
    @IgorStorozhuk 7 หลายเดือนก่อน

    Hello
    Please tell me how to get refresh token?

  • @miketepes8208
    @miketepes8208 9 หลายเดือนก่อน +1

    How about for logout? Mine not working

    • @CodeWithMasood
      @CodeWithMasood  9 หลายเดือนก่อน +1

      You can either clear the cookie if you are using it with backend!

    • @gaganvishwakarma6494
      @gaganvishwakarma6494 8 หลายเดือนก่อน

      Did you achieve logout functionality ? If yes then can you please share the code ?

    • @mephistolezz
      @mephistolezz 4 หลายเดือนก่อน

      @@gaganvishwakarma6494 when the page refreshes you are logged out, so I asume upon a reload you are logged out, but if you use your backend to save a cookie based on the token and compare it every time then you can make the logout button so that it removes the cookie and refreshes the page. But I don't think that's the best way so I'm waiting for his response too

  • @AnishBishnoi-wf7lv
    @AnishBishnoi-wf7lv 9 หลายเดือนก่อน +1

    how will token refresh after 1 hours ?

    • @CodeWithMasood
      @CodeWithMasood  9 หลายเดือนก่อน

      I didn't completely get your question however, if you want to delete the session or expire the token and make the user logout, you can store the token in db and when user login store the login with data in cookies or session and if the user logout delete the cookie simple!

    • @CodeWithMasood
      @CodeWithMasood  9 หลายเดือนก่อน

      similarly, you can delete the cookie in 1 hour using some time constraints.

  • @disismoyoutube
    @disismoyoutube 3 หลายเดือนก่อน

    I'm having trouble finding solutions for this extremely simple task. HOW TO IMPLEMENT LOGOUT?!!!!
    this is the problem with google, their documentation is alway terrible.

  • @lamtruong6344
    @lamtruong6344 4 หลายเดือนก่อน

    Can you logout using google API?

    • @mephistolezz
      @mephistolezz 4 หลายเดือนก่อน

      I also want to know this, I've been having issues with the log out

  • @daniyallodhi7765
    @daniyallodhi7765 11 หลายเดือนก่อน

    bro it is saying
    index.esm.js:83 Uncaught TypeError: onSuccessRef.current is not a function
    at bp.callback

    • @secretagent1004
      @secretagent1004 11 หลายเดือนก่อน

      Did you find a solution?

    • @secretagent1004
      @secretagent1004 11 หลายเดือนก่อน

      most likely it is because you are doing and not

    • @daniyallodhi7765
      @daniyallodhi7765 11 หลายเดือนก่อน

      ​@@secretagent1004ya bro that was a client id problem 😂

  • @kacperkepinski4990
    @kacperkepinski4990 8 หลายเดือนก่อน

    u say about 3000 and u write sth different...