Finally I got Token-based Authentication to work! ...
# suitescript
m
Finally I got Token-based Authentication to work! for all of you out there still having issues, I wrote this post on Medium. hopefully it will help someone netsuite😎 https://medium.com/@morrisdev/netsuite-token-based-authentication-tba-342c7df56386
💥 3
👍 6
h
May I share my snippet too, you need to have oauth and cryptojs imported
Copy code
var userName = runtime.getCurrentUser().name;
    	    var headers = oauth.getHeaders({
    	        url: config.IMPORT_ORDERS_RESTLET_URL,
    	        method: 'POST',
    	        tokenKey: config.TBA_TOKENS[userName]['tokenid'],
    	        tokenSecret: config.TBA_TOKENS[userName]['tokensecret']
    	    });
    	    var body = {
    	    	csvfileid: csvFileId,
    	    	sportscvfileid: sportsFileId
    	    };
    	    headers['Content-Type'] = 'application/json';
    	    var restResponse = <http://https.post|https.post>({
    	        url: config.IMPORT_ORDERS_RESTLET_URL,
    	        headers: headers,
    	        body: JSON.stringify(body)
    	    });