Trying to use/call a NetSuite Restlet with token based authentication using the Delphi RESTClient. I have a working Postman request that verifies all the authorization parameters required. The one parameter missing - realm - when added in code does change the error message returned from the NetSuite side but still doesn't result in a successful call.
procedure TForm1.OAuth1Authenticator1Authenticate(ARequest: TCustomRESTRequest;
var ADone: Boolean);
begin
// XXXXXXX_RP is a NetSuite account number and environment
ARequest.AddAuthParameter('realm','XXXXXX_RP',pkQUERY);
end;
If realm is not added (the above code is commented out) the returned rest content is:
error code: USER_ERROR
error message: header is not NLAuth scheme [ OAuth oauth_consumer_key="fe8da7b31dccbd47e90e5dd5e641fe7b0cbff032a951b4058618c207caf569f8", oauth_nonce="c98fa9de2c601f45bdc8d5c640f1b3cf", oauth_signature_method="HMAC-SHA1", oauth_signature="PfCQE3A4DicTtCfpBEPmbSOmqNg%3D", oauth_timestamp="1568639138", oauth_token="a8190ba34e223f25b32cdb4837d9e1973b8fd6208804e93306f4618ccdb6d648", oauth_version="1.0" ]
With realm added I still get:
error code: INVALID_LOGIN_ATTEMPT
error message: Invalid login attempt.
Anybody successfully make calls to NetSuite restlets using the Delphi RESTClient?
Update: Looks like it does not support using the optional realm parameter. Adding it manually gets it added to the normalized parameter list for signing when it shouldn't be. I have modified TOAuth1SignatureMethod_HMAC_SHA1.BuildSignature
in REST.Authenticator.OAuth
to skip this parameter (just added a if Lparam.Name <> 'realm' then begin .. end;
block around some code) but still no luck successfully making a request to NetSuite. Did this after reading https://oauth.net/core/1.0/ section 9.1.1. Normalize Request Parameters:
The request parameters are collected, sorted and concatenated into a
normalized string:
- Parameters in the OAuth HTTP Authorization header excluding the realm parameter.
- Parameters in the HTTP POST request body (with a content-type of application/x-www-form-urlencoded).
- HTTP GET parameters added to the URLs in the query part (as defined by [RFC3986] section 3).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…