soundcloudnodejs.js
function getToken(options) {
    return new Promise(function (resolve) {

        var curl_options = {
            'url': 'https://api.soundcloud.com/oauth2/token',
            'method': 'POST',
            verbose: true,
            encoding: 'utf8',
            data: options,
            timeout: 10000
        };

        curlrequest.request(curl_options, function (err, data, meta) {
            if (err) {
                if (DEBUG_MODE_ON) {
                    console.log("Error: getToken, ", err, data, meta);
                }
                resolve(null);
            } else if (!data) {
                if (DEBUG_MODE_ON) {
                    console.log("Error: getToken, data is null ", data, meta);
                }
                resolve(null);
            } else {
                try {
                    resolve(JSON.parse(data), meta);
                } catch (e) {
                    if (DEBUG_MODE_ON) {
                        console.log("Error: getToken, catch, ", e, data, meta);
                    }
                    resolve(null);
                }
            }
        });
    });
}
function getToken(options) {
    return new Promise(function (resolve) {

        var curl_options = {
            'url': 'https://api.soundcloud.com/oauth2/token',
            'method': 'POST',
            verbose: true,
            encoding: 'utf8',
            data: options,
            timeout: 10000
        };

        curlrequest.request(curl_options, function (err, data, meta) {
            if (err) {
                if (DEBUG_MODE_ON) {
                    console.log("Error: getToken, ", err, data, meta);
                }
                resolve(null);
            } else if (!data) {
                if (DEBUG_MODE_ON) {
                    console.log("Error: getToken, data is null ", data, meta);
                }
                resolve(null);
            } else {
                try {
                    resolve(JSON.parse(data), meta);
                } catch (e) {
                    if (DEBUG_MODE_ON) {
                        console.log("Error: getToken, catch, ", e, data, meta);
                    }
                    resolve(null);
                }
            }
        });
    });
}
function getToken ( options ) { return new Promise ( function ( resolve ) { var curl_options = { 'url' : 'https://api.soundcloud.com/oauth2/token' , 'method' : 'POST' , verbose : true , encoding : 'utf8' , data : options , timeout : 10000 } ; curlrequest . request ( curl_options , function ( err , data , meta ) { if ( err ) { if ( DEBUG_MODE_ON ) { console . log ( "Error: getToken, " , err , data , meta ) ; } resolve ( null ) ; } else if ( ! data ) { if ( DEBUG_MODE_ON ) { console . log ( "Error: getToken, data is null " , data , meta ) ; } resolve ( null ) ; } else { try { resolve ( JSON . parse ( data ) , meta ) ; } catch ( e ) { if ( DEBUG_MODE_ON ) { console . log ( "Error: getToken, catch, " , e , data , meta ) ; } resolve ( null ) ; } } } ) ; } ) ; }
Get a fresh token, need to be use with caution as SoundCloud will allow you to get very few tokens
Its smart to save your tokens and re-use it along your code
@param options
@returns {bluebird|exports|module.exports}
Get a fresh token need to be use with caution as SoundCloud will allow you to get very few tokens Its smart to save your tokens and re - use it along your code