I have a program for integration with OAuth2 and Google Spring, where I can access protected resources such as user profile, etc.
I think you need to reorganize the code to use the following code:
OAuthClientRequest request = OAuthClientRequest .authorizationLocation("https://accounts.google.com/o/oauth2/auth") .setClientId("") .setRedirectURI("https://test.example.com/oauthtest/oauth/google/auth") .setResponseType("code") .setScope("https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.profile.emails.read https://www.googleapis.com/auth/plus.me") .buildQueryMessage();
Also, when you handle the callback, you need to make sure that you send the value "secret", "TokenLocation", "RedirectURI" and above the "code", which must be set for setCode ("")
Please write my answer from Apache Oltu Spring OAuth2 Security and Google Integration . Make sure your code details are set correctly.
Prateek
source share