Reputation: 333
I have created a NetSuite Saved Search to fetch some data. I have written a SuiteScript to access Saved Search and fetch data. The SuiteScript is also deployed.
I tested the SuiteScript by postman using OAuth 1 authentication flow and its success.
I need to access the same SuiteScript by SOAP request and integrate it using Ballerina.
How can I integrate the OAuth in ballerina and access the SuiteScript?
Upvotes: 0
Views: 337
Reputation: 1122
import ballerina/http;
import ballerina/io;
import ldclakmal/oauth1;
public function main() returns error? {
oauth1:ClientOAuthHandler oauthHandler = new({
signatureMethod: oauth1:HMAC_SHA1,
consumerKey: "dpf43f3p2l4k3l03",
consumerSecret: "kd94hf93k423kf44",
accessToken: "hh5s93j4hdidpola",
accessTokenSecret: "pfkkdhi9sl3r4s00",
realm: "Photos",
nonce: "7d8f3e4a"
});
map<string|string[]> securityHeaders = check oauthHandler.getSecurityHeaders("GET",
"https://photos.example.net/request?type=jpg&maxsize=10mb");
final http:Client clientEP = check new("https://photos.example.net");
json payload = check clientEP->get("/request?type=jpg&maxsize=10mb", securityHeaders);
io:println(payload);
}
Upvotes: 2