Soundcloud API Authentication | NodeWebkit, uri redirection and local file system

I am trying to create a NodeWebkit application that uses the Soundcloud API.
But I fail already in the process of connecting / logging in.

In NodeWebkit, a user can install the application anywhere on his hard drive.
so redirect_uri will never be the same again.
And placing the redirect page on the web server will not work.
{various protocols "file: //" and "https: //")

I tried various approaches from the Doku API here
http://developers.soundcloud.com/docs#authentication but with no result.

How do I use the Soundcloud API with NodewebKit?

Thanks in advance.

+4
source share
2 answers

After detecting NodeWebkit, Issue`s saw this stream: https://github.com/rogerwang/node-webkit/issues/542

It describes a method with IFrames NodeWebkit: my code is as follows:

var def = $.Deferred(); var $iframe = $('<iframe nwfaketop nwdisable></iframe>') .attr('src', SoundCloud.ConnectUrl) .load(function(e) { var parser = document.createElement('a'); parser.href = this.contentWindow.location.href; var search = parser.search.substr(1, parser.search.length); var result = URLToArray(search); if (result.error !== void 0) { $iframe.remove(); def.reject(result.error_description); } if (result.code !== void 0) { SoundCloud.LoginCode = result.code; $iframe.remove(); def.resolve(); } }) .appendTo($(opts.iframe)); return def; 

Hope this helps others with the same problem.

+2
source

For a file-based solution, perhaps you can create a local redirect_uri each time with the __dirname __filename variables of the node module.

For a web server based solution, since the node_remote attribute allows you to call node apis in the localhost "localhost" or something else, you should be able to synchronize soundcloud data using callback.html (like your connection page) through the context in node.

+1
source

Source: https://habr.com/ru/post/1502030/


All Articles