Skip to content

Examples #1

@ghost

Description

Hi, thanks for this package. I am a newbie writing some suitescripts, and need to get this oauth working for accessing a restlet. I can't seem to get this to work and and I'm not familiar with the way the functions are written.

I have a suitelet (externally available script) that I am putting this code into - which then accesses a restlet with needs the Oauth authentication.

Normally, I just write a function on the suitelet like:

function getData(request,response) {
...
var restReponse = https.get....
....
}

And I have included the crypto.js and oauth.js in the library tab of the script.

In this code provided
require(['N/https', '/SuiteScripts/oauth', '/SuiteScripts/secret'], function(https, oauth, secret) {

it doesn't seem to work - I just get errors.

I have tried re-writing like this:
function getData(request,response) {

var https = require('N/https');
//var secret = require('/SuiteScripts/secret');
var oauth = require('/SuiteScripts/oauth');

var secret = new Object();
secret.token.public ='xxxx';
secret.token.secret = 'xxxx';
secret.consumer.public = 'xxxx';
secret.consumer.secret = 'xxxx';
secret.realm = 'xxxxx';

But I get the error:
ReferenceError: "define" is not defined. (oauth.js#1)

Could you help a newb out? Maybe provide an example of how to get this into what I am doing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions