Redirect_uri and how to place callback.html in SoundCloud?

I am trying to access Soundcloud from a local HTML page on my laptop. I am stuck on the hosting part of "callback.html" as redirect_uri. script I am trying to run a basic authentication script on the Soundcloud documentation page:

<script src="http://connect.soundcloud.com/sdk.js"></script> <script> // initialize client with app credentials SC.initialize({ client_id: 'my_client_id', redirect_uri: 'http://127.0.0.1/Users/Maria/Documents/SoundcloudClient/callback.html' }); // initiate auth popup SC.connect(function() { SC.get('/me', function(me) { alert('Hello, ' + me.username); }); }); </script> 

This script returns me to the connection popup when the page starts in Chrome and Firefox. But, as soon as I registered as a Soundcloud user, I get the following error:

 Oops! Google Chrome could not connect to 127.0.0.1 

If I change my redirect_uri to localhost, I get the same error.

If I try:

 files:///C:/Users/Maria/Documents/SoundcloudThinClient/callback.html 

I get a similar error.

I also tried:

 ocalhost:3000 

and

 localhost:8080 

although I'm not sure I will listen to these ports.

So basically, I am asking which way do I use for callback.html for this to work?

I admit, I do not know how redirct_uri works. I looked at the Oauth pages, but I do not understand them. I am starting to think that I cannot just create an HTML page, insert JavaScript, create a callback.html file and do the job, even if the SC documentation seems to say that this is possible. If so, what steps am I missing?

+4
source share
2 answers

I'm starting to try to do it. I believe that you need to go to the developer's site and register as an application. A uri redirect is required, and the form gives you an API key that you can use in your application.

I use drupal, so maybe adding an oath module and using Php to add an api key might work well.

+1
source

I had the same problem and decided that I had solved.

Morning-after-edit: I posted this dead tiredness after working on a solution overnight. Now, the next day, I understand that you were talking about a general problem that I am facing with a very specific example. The following only applies to registering the soundcloudlabs sound keyboard: https://github.com/soundcloudlabs/soundcloud-group-recorder . There is probably a more general principle behind it:

First: yes, you need to register the application as your own in Soundcloud. At least I assumed so. And by doing this, you must correctly register where on your server you put the callback.html file. Take the ClientID assigned to your application and use it in the API initialization procedure.

Now I am new and know very little coding. But I started looking in the main application.js file.

  • At the top of the file there are two instances of client_id and redirect_uri each. I am not sure if this serves the purpose, or if technically redundant. Through a trial version and an error, I found that replacing a second instance of each of my own data worked.

  • Then there are groupId and groupUrl, both of which should contain your information in quotation marks.

  • After a lot of trial and error, still having problems with what needs to be started, I looked around and saw this, while at the beginning of the file client_id was connected to SC.initialize, redirect_uri was not. Under the line:

client_id: CLIENT_ID

I added:

redirect_uri: REDIRECT_URI

- with an ordinary comma between them. And so it is. He works.

+1
source

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