1
votes

Using play-ws 2.4.6 and the NingWSClient, is it possible to set the realm in the Authentication header? I am trying to hit NetSuite's REST 1.0 API which requires the OAuth realm parameter to be set.

Here is some sample code I am currently using:

val requestToken = RequestToken("*****", "*****")
val consumerKey = ConsumerKey("*****", "*****")
val oauthCalc = OAuthCalculator(consumerKey, requestToken)

val request: WSRequest =  ws.url("https://rest.na1.netsuite.com/app/site/hosting/restlet.nl?script=554&deploy=1")
  .withHeaders("Content-Type" -> "application/json").sign(oauthCalc)
request.get()

Netsuite does not recognize the OAuth request without the realm, reporting: USER_ERROR header is not NLAuth scheme. Using the Postman rest app, I was able to reproduce the same error from NetSuite when a realm is not supplied. Then when adding the realm in postman the request went through successfully.

1
Oauth 1 or 2? Also, I think you can set the realm manually as part of the Authorization headerTonyH
Oauth 1.0. When setting the realm manually in the Authorization header, the .sign method overwrites the Authorization header and does not append to it. I was able to get around this issue by creating the HMAC-SHA1 signature myself, and manually building out the Authorization header instead of using the .sign method.awells

1 Answers

0
votes

I was able to get around this issue by creating the HMAC-SHA1 signature myself, and manually building out the Authorization header instead of using the .sign method.