Oauth 1.0a Auth header For NetSuite

by Gerald Gillespie

HTML

<p>
This fiddle generates an OAuth 1.0a Authorization header for NetSuite
</p>
<textarea id="myTextArea" name="output" cols=100 rows=10></textarea>

JavaScript

//this information is supplied during the creation of your application and related linking to the role
var inputData = {tokensecret : '65c26784496ed68ac795543473511e6b6b429051d86c874a6b7f4e4e789464df', 
consumerkey : 
'eb6f703adfe17ab216a44db6e16e38c7f77ddc9f66e0b999e667905a628bfaaa',
realm :
'3709217_SB3',
consumersecret :
'aad1653f78a3ef1b53b50cf9f7beb11d4742ba1e7e79e793cc0e3398bd68221c',
tokenid : 
'859ff0d442da91d31f0d2a1b7263a82774a264da25495b6be8239d0471cbbe07',
host : 'https://3709217-sb3',
uri : 'restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=367&deploy=1',
method : 'POST'
};


var secret = {
        consumer: {
            public: inputData.consumerkey,
            secret: inputData.consumersecret
        },
        token: {
            public: inputData.tokenid,
            secret: inputData.tokensecret
        },
        realm: inputData.realm
    };

/****************************************** END secret ***/


var Crypto = function() {

    // Here begins rollups/hmac-sha1.js

    /*
     CryptoJS v3.1.2
     code.google.com/p/crypto-js
     (c) 2009-2013 by Jeff Mott. All rights reserved.
     code.google.com/p/crypto-js/wiki/License
     */
    var CryptoJS=CryptoJS||function(g,l){var e={},d=e.lib={},m=function(){},k=d.Base={extend:function(a){m.prototype=this;var c=new m;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
            p=d.WordArray=k.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=l?c:4*a.length},toString:function(a){return(a||n).stringify(this)},concat:function(a){var...