oltu-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jasha Joachimsthal <ja...@apache.org>
Subject Re: Microsoft OAuth2 Question
Date Fri, 09 Jan 2015 07:14:51 GMT

My experience is that you cannot just copy-paste the implementation if
you connect with the big public oAuth providers. Most of them have
their own quirks. The following code works for me to get a profile of
a Microsoft account.

Substitute the clientId, clientSecret and redirectUri parameters with
the ones you have configured at Microsoft and handle the state
parameter properly. The scope wl.signin is the minimal scope at

Authorization request:

OAuthClientRequest oAuthClientRequest = OAuthClientRequest

String authzLocation = oAuthClientRequest.getLocationUri()

Get AccessToken:

String getAccessToken(final OAuthAuthzResponse oar)
    throws OAuthSystemException, OAuthProblemException {
  final String code = oar.getCode();
  final OAuthClientRequest oAuthClientRequest = OAuthClientRequest

  final OAuthAccessTokenResponse accessTokenResponse =
  return accessTokenResponse.getAccessToken();

Get Profile:
final OAuthClientRequest bearerClientRequest = new

return getoAuthClient().resource(bearerClientRequest,
OAuth.HttpMethod.GET, OAuthResourceResponse.class);



On 8 January 2015 at 22:41, Tiburtius, Ashwanth [IWD]
<Ashwanth.Tiburtius@iwd.iowa.gov> wrote:
> Hi,
> I am doing a poc to use Apache Oltu for user authentication against Google,
> Microsoft and Yahoo. I was able to successfully use the client demo provided
> by Apache Oltu to authenticate a user in Google using gmail credentials and
> also retrieve user information. But I am running into issues while trying to
> do the same for Microsoft. Following are the details I have entered but I
> keep getting the error “Error: Incorrect parameters: Redirect URI” even
> though the redirect uri matches the one configured in the API settings in
> Microsoft Development Center. This could be a Microsoft question but I would
> highly appreciate any help that you can provide. Google was quit straight
> forward to setup and execute but Microsoft is confusing to say the least.
> Hoping Apache Oltu would make life easier.
> Requested Access Scope: wl.signin
> End-User Authorization URL: https://login.live.com/oauth20_authorize.srf
> Token Endpoint: https://login.live.com/oauth20_token.srf
> Client ID: <Correct value entered>
> Client Secret: <Correct value entered>
> Redirect URI: http://iwd.gov/profile/register (This is the value entered in
> the API settings)
> Thanks,
> Jude.
> Iowa Workforce Development – IT | 1000 E Grand Ave, Des Moines, IA  50319
> (515) 281-3378 | Ashwanth.Tiburtius@iwd.iowa.gov

View raw message