public UserInfoResponse getUserInfo ( String accessToken ) throws OpenIdException { logger . debug ( "Enter OAuth2PlatformClient::getUserInfo" ) ; try { HttpRequestClient client = new HttpRequestClient ( oauth2Config . getProxyConfig ( ) ) ; Request request = new Request . RequestBuilder ( MethodType . GET , oauth2Config . getUserProfileEndpoint ( ) ) . requiresAuthentication ( true ) . authString ( "Bearer " + accessToken ) . build ( ) ; Response response = client . makeRequest ( request ) ; logger . debug ( "Response Code : " + response . getStatusCode ( ) ) ; if ( response . getStatusCode ( ) == 200 ) { ObjectReader reader = mapper . readerFor ( UserInfoResponse . class ) ; UserInfoResponse userInfoResponse = reader . readValue ( response . getContent ( ) ) ; return userInfoResponse ; } else { logger . debug ( "failed getting user info" ) ; throw new OpenIdException ( "failed getting user info" , response . getStatusCode ( ) + "" ) ; } } catch ( Exception ex ) { logger . error ( "Exception while retrieving user info " , ex ) ; throw new OpenIdException ( ex . getMessage ( ) , ex ) ; } }
Method to retrieve UserInfo data associated with the accessToken generated The response depends on the Scope supplied during openId