oltu-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tiburtius, Ashwanth [IWD]" <Ashwanth.Tiburt...@iwd.iowa.gov>
Subject RE: Google OpenID Connect Authentication example
Date Tue, 17 Mar 2015 15:53:55 GMT
Hi Saqib,

See if this helps:

Build request to redirect to Google.

OAuthClientRequest request = OAuthClientRequest.authorizationProvider(OAuthProviderType.GOOGLE)
                                                .setClientId(Constants.G_CLIENT_ID
                                                .setResponseType(OAuth.OAUTH_CODE)
                                                .setScope(Constants.G_SCOPE)
                                                .setRedirectURI(Constants.OAUTH_REDIRECT_URL)
                                                buildQueryMessage();

Redirect to request.getLocationUri()

Get the auth code returned from Google after user signs in.
Get access token using the following.
OAuthClientRequest oAuthClientRequest = OAuthClientRequest.tokenProvider(OAuthProviderType.GOOGLE)
                                                                     .setGrantType(GrantType.AUTHORIZATION_CODE)
                                                                     .setClientId(Constants.G_CLIENT_ID)
                                                                     .setClientSecret(Constants.G_CLIENT_SECRET)
                                                                     .setRedirectURI(Constants.OAUTH_REDIRECT_URL)
                                                                     .setCode(this.code).buildBodyMessage();

final OAuthAccessTokenResponse accessTokenResponse = oAuthClient.accessToken(oAuthClientRequest);
accessToken = accessTokenResponse.getAccessToken();

Get User info using the following.
final OAuthClientRequest bearerClientRequest = new OAuthBearerClientRequest(Constants.G_USERINFO_URL)
                                                                         .setAccessToken(accessToken)
                                                                         .buildHeaderMessage();

OAuthResourceResponse resourceResponse = oAuthClient.resource(bearerClientRequest,
OAuth.HttpMethod.GET, OAuthResourceResponse.class);
resourceResponse.getBody()


Regards,
Jude.
Iowa Workforce Development – IT | 1000 E Grand Ave, Des Moines, IA  50319
(515) 281-3378 | Ashwanth.Tiburtius@iwd.iowa.gov<mailto:Ashwanth.Tiburtius@iwd.iowa.gov>

From: Saqib Ali [mailto:saqib.n.ali@seagate.com]
Sent: Monday, March 16, 2015 8:20 PM
To: user@oltu.apache.org
Subject: Google OpenID Connect Authentication example

Greetings,

Can anyone please send me a Google OpenID Connect Authentication example using the Oltu Open
Connect library?

Thanks! :)
Mime
View raw message