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. )?
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
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 ?
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
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
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
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.
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 .
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.
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.
@@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.
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.
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 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 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 ..
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...
You make some very good videos. Very succinct and to the point. Good job
Thank you so much
@codeWithRaman i update your code for version 3.25 and Java SDK 21 .
Watch the modify .It works
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. )?
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
On clicking login with google or login with git hub I am getting 404 error
Can you please help me
Hi. Please can you share console logs on ramanpopli19@gmail.com
Thanks you very match for this video, it's very helpful and especially thanks for the sharing of repo it's very kind
Thank you
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 ?
Hello thanks for commenting .The video is not made yet .I am working on it
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
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
Hi, how we can produce json (RESTController) rather than Model on succeshandler?
I want to produce json to client once authenticated from google.
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
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.
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 .
Thank you. You realy helped me
Great 👍
How to perform same thing using angular plus spring boot rest
Yes it is possible to do it .But yes I have plans to make video on that too .Soon will plan
When i try login with google, google throw "Error 400: redirect_uri_mismatch"
Hi , please check the redirect URL that you are configuring while generating Client_ID and Secrete .There might be some discrepancy
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.
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.
@@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.
@@rajeevjayaram4981 sure I'll cover this
Great Video, helped a lot 🔥🔥
Thanks
How o get access token using postman
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.
hi, can u pls tell me is there anyway i can get hold of the access and refresh token from the client
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
@@codeWithRaman it is not requesting a new token but getting hold of existing tokens..from which we can retrieve info
@@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?
@@rajeevjayaram4981 or are you talking about Jwt token
@@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 ..
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
Sure can you share the console logs or maybe your code repository.I can check n revert .
@@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.
can you tell me how to retrieve Register data to MongoDB ?
Thanks for writing, you want to connect to mongodb for custom registration and login right?
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...
Hi Ravi, I have already given you a reply in your pervious comment. Can you confirm on that
brother first i registered but after login time it tells password wrong what can i do now
Hello , can you share the screenshot of the error in your IDE console
@@codeWithRaman yes bro please tell your telegram account name
@@bhavanisankar71 hello, can you share it on my email Id - ramanpopli19@gmail.com . It would be better
@@codeWithRaman ok bro i will share in after noon
brother i send screenshots in email so once check
brother do one separate video database registraion and login time email and password only !!!!!
In process
helpful
Thanks
Use dark mode dude
Sure
Hi bro i nee your help , i have paid work for you
Hello brother, you can contact on email