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 ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Oauth using Java instead of curl with apache oltu.

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

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

curl -k https://api.bp-services.com/ --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(OAuthProblemException.java:63)
at org.apache.oltu.oauth2.client.response.OAuthJSONAccessTokenResponse.setBody(OAuthJSONAccessTokenResponse.java:70)
at org.apache.oltu.oauth2.client.response.OAuthClientResponse.init(OAuthClientResponse.java:56)
at org.apache.oltu.oauth2.client.response.OAuthAccessTokenResponse.init(OAuthAccessTokenResponse.java:52)
at org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory.createCustomResponse(OAuthClientResponseFactory.java:60)
at org.apache.oltu.oauth2.client.URLConnectionClient.execute(URLConnectionClient.java:111)
at org.apache.oltu.oauth2.client.OAuthClient.accessToken(OAuthClient.java:65)
at org.apache.oltu.oauth2.client.OAuthClient.accessToken(OAuthClient.java:55)
at nl.sligro.leverdatumbepaling.test.LDBGetCertificaat.callGetToken(LDBGetCertificaat.java:55)
at nl.sligro.leverdatumbepaling.test.LDBGetCertificaat.main(LDBGetCertificaat.java:28)



Any body have an idea whats wrong with my code?

Thanks in advance,

Kind Regards,

Ben
 
a wee bit from the empire
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic