I developed an example of Apache Oltu and Spring , and it works great on my end.
You need to enable the Google+ API, as suggested by @prtk_shah. Thanks.
You need to go to https://console.developers.google.com/project?authuser=0 and click on your project, in my case it is "apache-oltu", in your open the API APIs and auth โ API Find the Google+ API and enable it.
Here you can see this screen. 
So, I will modify your code below, it should look like this:
(IMP). Your customer ID should be like this: For example: (755670439314-jcumfghnkmcm72hf40beikvoatknstml.apps.googleusercontent.com), please make sure that it is correct. Fyi is use as it is provided by the Google Developer Console.
OAuthClientRequest request = OAuthClientRequest .authorizationLocation("https://accounts.google.com/o/oauth2/auth") .setClientId("3kT21Hlkzzt5eV1.apps.googleusercontent.com") .setRedirectURI("Give your projects redirect URI") .setResponseType("responsecode") .setScope("openId profile email") .buildQueryMessage();
The callback code should be:
private void getAccessToken(String authorizationCode) throws OAuthSystemException, OAuthProblemException { OAuthClientRequest request = OAuthClientRequest .tokenLocation("https://accounts.google.com/o/oauth2/token") .setGrantType(GrantType.AUTHORIZATION_CODE) .setClientId("give your complete client id") .setClientSecret("give your secret") .setRedirectURI("This will be your callback or Redirect URL (Give it correctly)") .setCode(authorizationCode) .buildBodyMessage();
This is what I get in my example, I just wanted to show you

Hope this will be helpful.
Prateek
source share