Oauth2.0: Spring boot Login with Google/GitHub | With Custom Register And Login

Поділитися
Вставка
  • Опубліковано 26 жов 2024

КОМЕНТАРІ • 63

  • @happybuddha13
    @happybuddha13 9 місяців тому

    You make some very good videos. Very succinct and to the point. Good job

    • @codeWithRaman
      @codeWithRaman  9 місяців тому +1

      Thank you so much

    • @sebastianocantore3487
      @sebastianocantore3487 5 місяців тому

      @codeWithRaman i update your code for version 3.25 and Java SDK 21 .
      Watch the modify .It works

  • @tranthingochoai6134
    @tranthingochoai6134 Рік тому +1

    Hi, how can I get another information like phone num, gender, etc. from Google when using DefaultOAuth2User userDetails ( i mean how can I get the attributes/keys name like "email", "login", "name", etc. )?

    • @codeWithRaman
      @codeWithRaman  Рік тому

      Hi , thanks for writing , when you are asking about the email Id , name and all you can get these as you can check I have fetched in CutomsuccessHandler.java using
      DefaultOAuth2User userDetails = (DefaultOAuth2User ) authentication.getPrincipal();
      userDetails.getAttribute("email").
      But for phoneNumber , Gender , these need to be allowed from the users account to allowed to share right , and then to do that you have to have a scope of 'user.phonenumbers.read' , but as this is sensitive information . I guess for practicing you can do it .
      If any other info required you can write me at - ramanpopli19@gmail.com

  • @playwithknight007
    @playwithknight007 Рік тому +1

    On clicking login with google or login with git hub I am getting 404 error
    Can you please help me

    • @codeWithRaman
      @codeWithRaman  Рік тому

      Hi. Please can you share console logs on ramanpopli19@gmail.com

  • @devall4324
    @devall4324 Рік тому

    Thanks you very match for this video, it's very helpful and especially thanks for the sharing of repo it's very kind

  • @superpatata93
    @superpatata93 Рік тому

    hello i see some comment talking about a video in a full stack app with a react client or other and a spring boot backend api, but i dont see your tutorial video did you record it ?

    • @codeWithRaman
      @codeWithRaman  Рік тому +1

      Hello thanks for commenting .The video is not made yet .I am working on it

  • @sumitchouhan8716
    @sumitchouhan8716 Рік тому

    Great explanation, thank you , can you help how can I implement this latest version of spring boot 3.2.0 version with java 20, it is showing deprecated ant matcher , please help or share link how can use ant matcher in this version

    • @codeWithRaman
      @codeWithRaman  Рік тому

      Hi , Thanks for commenting and allowing me to do a little brainstorming . So , there will be a lot of changes I guess as persistence package is been removed from java 11 onwards so you will have to use Jakarta package . Then your question about security . So , in SpringSecurity 6.0 antMatchers and many other are been deprecated you can see the reason here : github.com/spring-projects/spring-framework/issues/28552 . And to suggest you a solution you can do it something like this : http
      .authorizeHttpRequests(requests -> requests
      .requestMatchers("/vertretungsplan").hasAnyRole("SCHUELER", "LEHRER", "VERWALTUNG")
      .anyRequest().authenticated()
      ) .
      Complete reference : stackoverflow.com/questions/74753700/cannot-resolve-method-antmatchers-in-authorizationmanagerrequestmatcherregis

  • @shashankmanitripathi7335
    @shashankmanitripathi7335 Рік тому

    Hi, how we can produce json (RESTController) rather than Model on succeshandler?
    I want to produce json to client once authenticated from google.

    • @codeWithRaman
      @codeWithRaman  Рік тому

      Ok you don't want to make a user land on dashboard after login success you want to hit it as the Rest api and you need json response. So, for that you will need and api that will hit the same url which we are hitting when we click on login with Google with your credentials from may be postman or any other tool that will return a token right, then further you can append that token as bearer token in any other api you want to hit, rather than writing a successHandler

  • @MohammadAli-pt6jq
    @MohammadAli-pt6jq Рік тому +1

    Hi, Excellent! I have gone through the entire flow and tried to implement with MySQL (doesn't matter postgres/mysql) however I'm getting org.springframework.security.oauth2.core.OAuth2AuthorizationException: [invalid_token_response] An error occurred while attempting to retrieve the OAuth 2.0 Access Token Response: 401 Unauthorized: [no body]. I'm using spring boot 2.7.5. Tried to get the answers but no luck. The same working fine with Spring 2.2.x version. Appreciate if you can throw some light. Thanks a lot. I tried with Google only not with Github.

    • @codeWithRaman
      @codeWithRaman  Рік тому

      Hi , Thanks for your comment . Please can you double check the client id and secrete you have configured and also the endpoint . Look Postgres or MySQL that do not matter . As the code I have implemented is also on Spring version 2.7.x . So , the problem could be in the clientId ,secrete or endpoint configuration .

  • @Dirty_Star
    @Dirty_Star Рік тому

    Thank you. You realy helped me

  • @luckytheracer4557
    @luckytheracer4557 Рік тому

    How to perform same thing using angular plus spring boot rest

    • @codeWithRaman
      @codeWithRaman  Рік тому

      Yes it is possible to do it .But yes I have plans to make video on that too .Soon will plan

  • @pablomanchonrichardi8283
    @pablomanchonrichardi8283 Рік тому

    When i try login with google, google throw "Error 400: redirect_uri_mismatch"

    • @codeWithRaman
      @codeWithRaman  Рік тому

      Hi , please check the redirect URL that you are configuring while generating Client_ID and Secrete .There might be some discrepancy

  • @rajeevjayaram4981
    @rajeevjayaram4981 Рік тому

    Superbly explained. My doubt here is in the local login, how should I configure if i want to use Spring Authorization server as a authoorization server or keycloak. Can u pls extend this app i possible...Thanks for the video.

    • @codeWithRaman
      @codeWithRaman  Рік тому +1

      Sure. You want me to cover tha Spring Authorization as a client as well as Resource server. Right?
      That all requests get authorized through spring auth server.
      I will cover that soon.

    • @rajeevjayaram4981
      @rajeevjayaram4981 Рік тому

      @@codeWithRaman Yes Exactly...thanks..this would be the best tutorial as a real project scenario.rightnow what Iam doing is spliiting the appserver, resource and ui (thymeleaf ) etc into a seperate microservice..that will help in clear seperation .thanks once again...the video is awesome...One more topic you can cover is inter microservice commuincation to do data transfer. If you have already covered that in any other videos please let me know in which video and i will go thru that..to see your approach.

    • @codeWithRaman
      @codeWithRaman  Рік тому +1

      @@rajeevjayaram4981 sure I'll cover this

  • @shoryarawat9835
    @shoryarawat9835 Рік тому

    Great Video, helped a lot 🔥🔥

  • @manojkshirapthi944
    @manojkshirapthi944 10 місяців тому +1

    How o get access token using postman

    • @codeWithRaman
      @codeWithRaman  10 місяців тому

      Hi thanks for commenting. After configuring your Springboot application with client I'd and secret and then you can go to postman after running application
      POST request and provide the token endpoint URL. This is usually accounts.google.com/o/oauth2/token and provide the required parameters like grant_type, code, client_id, client_secret, and redirect_uri.
      Send the request, and you should receive an access token in the response.

  • @rajeevjayaram4981
    @rajeevjayaram4981 Рік тому

    hi, can u pls tell me is there anyway i can get hold of the access and refresh token from the client

    • @codeWithRaman
      @codeWithRaman  Рік тому

      If you want to get the access token from the client ,like from google , you have to use different library and then you can request for the access token

    • @rajeevjayaram4981
      @rajeevjayaram4981 Рік тому

      @@codeWithRaman it is not requesting a new token but getting hold of existing tokens..from which we can retrieve info

    • @codeWithRaman
      @codeWithRaman  Рік тому

      @@rajeevjayaram4981 If I am correct let me know that i understood your question right or not. When I click on Login with Google. You want the token of that transaction?

    • @codeWithRaman
      @codeWithRaman  Рік тому

      @@rajeevjayaram4981 or are you talking about Jwt token

    • @rajeevjayaram4981
      @rajeevjayaram4981 Рік тому

      @@codeWithRaman I am talking about jwt access token for users logged in using thymeleaf. Example in controller I want to use token to extract client id details ..

  • @Akshay-m8g5y
    @Akshay-m8g5y Рік тому

    Hi Ramanpreet,
    After running the app. It's not taking me to the dashboard page. Its redirection back to login.html page.
    Could you please help

    • @codeWithRaman
      @codeWithRaman  Рік тому +1

      Sure can you share the console logs or maybe your code repository.I can check n revert .

    • @Akshay-m8g5y
      @Akshay-m8g5y Рік тому

      @@codeWithRaman Got it fixed. It wasn't redirecting to dashboard because of jwt token. Turns out I had to set to correct time. Thanks for your reply.

  • @kolithamalan2371
    @kolithamalan2371 Рік тому

    can you tell me how to retrieve Register data to MongoDB ?

    • @codeWithRaman
      @codeWithRaman  Рік тому

      Thanks for writing, you want to connect to mongodb for custom registration and login right?

  • @RaviYadav-cx2pb
    @RaviYadav-cx2pb Рік тому

    Hi Could you please a new project on making complex report on spring data jpa .. on the basis of cascading drop-down list using ajax make a report... For example on the of state and district give employees details.. the data populate on cascading drop-down list should be come from database...

    • @codeWithRaman
      @codeWithRaman  Рік тому

      Hi Ravi, I have already given you a reply in your pervious comment. Can you confirm on that

  • @bhavanisankar71
    @bhavanisankar71 Рік тому

    brother first i registered but after login time it tells password wrong what can i do now

    • @codeWithRaman
      @codeWithRaman  Рік тому

      Hello , can you share the screenshot of the error in your IDE console

    • @bhavanisankar71
      @bhavanisankar71 Рік тому

      @@codeWithRaman yes bro please tell your telegram account name

    • @codeWithRaman
      @codeWithRaman  Рік тому

      @@bhavanisankar71 hello, can you share it on my email Id - ramanpopli19@gmail.com . It would be better

    • @bhavanisankar71
      @bhavanisankar71 Рік тому

      @@codeWithRaman ok bro i will share in after noon

    • @bhavanisankar71
      @bhavanisankar71 Рік тому

      brother i send screenshots in email so once check

  • @bhavanisankar71
    @bhavanisankar71 Рік тому

    brother do one separate video database registraion and login time email and password only !!!!!

  • @abhishekanand2991
    @abhishekanand2991 4 місяці тому

    helpful

  • @aliksargsyan2782
    @aliksargsyan2782 Рік тому

    Use dark mode dude

  • @Unknown-oh7hg
    @Unknown-oh7hg Рік тому

    Hi bro i nee your help , i have paid work for you