Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

Oauth using Java instead of curl with apache oltu.

Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I want to replace this curl command with a request in a Java client:

curl -k --user userName:SecretID –d "scope=/LeverdatumbepalingRest/api/v1.0/"

It is returning an JSON message and it look like this:

{ "token_type":"bearer", "access_token":"AAEecmVzdC10b2tlbi1zcnYtcGFzc3dvcmQtY2xpZW50zBVd4EcoSnA5zVHOHSMkSN-ReEgOnAuyQxv3jv613vQvonMGU_HxjWbzNJPfadc1L0ZSA4dar0YCR8Jx7PSvkue_2Lh7lOQ9Nv8KGRz092OgLR_A2TGD6e6zafsgpaMB", "expires_in":2678400, "scope":"/LeverdatumbepalingRest/api/v1.0/" }

The request goes to a IBM Datapower server with an webtoken implementation.

I tried it in Java with Apache oltu lib: org.apache.oltu.oauth2.client-1.0.1.jar

I tried to build a Java client with this code but it is not working, the server even does not receive any message so my client is not working:

This error I am getting:

Exception in thread "main" OAuthProblemException{error='unsupported_response_type', description='Invalid response! Response body is not application/json encoded', uri='null', state='null', scope='null', redirectUri='null', responseStatus=0, parameters={}}
at org.apache.oltu.oauth2.common.exception.OAuthProblemException.error(
at org.apache.oltu.oauth2.client.response.OAuthJSONAccessTokenResponse.setBody(
at org.apache.oltu.oauth2.client.response.OAuthClientResponse.init(
at org.apache.oltu.oauth2.client.response.OAuthAccessTokenResponse.init(
at org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory.createCustomResponse(
at org.apache.oltu.oauth2.client.URLConnectionClient.execute(
at org.apache.oltu.oauth2.client.OAuthClient.accessToken(
at org.apache.oltu.oauth2.client.OAuthClient.accessToken(
at nl.sligro.leverdatumbepaling.test.LDBGetCertificaat.callGetToken(
at nl.sligro.leverdatumbepaling.test.LDBGetCertificaat.main(

Any body have an idea whats wrong with my code?

Thanks in advance,

Kind Regards,

a wee bit from the empire
Free, earth friendly heat - from the CodeRanch trailboss
    Bookmark Topic Watch Topic
  • New Topic