javascript - How to use Soundcloud API (authentication) with Angular.js -


i can use public soundcloud api, struggling callback.html login dialog.

at soundcloud app has following callback redirect uri callback.html: http://localhost:8080/#/callback

on route angular app defines controller desired callback template:

<!doctype html> <html lang="en">     <head><meta http-equiv="content-type" content="text/html; charset=utf-8">         <title>connect soundcloud</title>     </head>     <body onload="window.opener.settimeout(window.opener.sc.connectcallback, 1)">         <b style="width: 100%; text-align: center;">this popup should automatically close in few seconds</b>     </body> </html> 

in root controller defined:

sc.initialize({     client_id: "####",     redirect_uri: "http://localhost:8080/#/callback", }); 

thats why public api works me @ controller:

sc.get('/resolve', {      url: 'https://soundcloud.com/someuser' }, function(user) {     console.log(user); }); 

but in same controller following returns 401:

sc.get('/me', function(me) {     console.log(me); }); 

sure, because there no dialog popping login!

so did wrong setting callback.html?

my assumptions:

  1. is it, because there /#/ in url? tried <base href="/"> , $locationprovider.html5mode(true); didn't change anything.

  2. is it, because should serve callback.html not in spa environment. more independent static page?

  3. is there wrong mapping callback.html?

  4. i using webpack build tool. there wrong that?

  5. do have set else redirect uri @ soundcloud app?

i hope can me that!

my website angularjs+soundcloud too, sure, dont see sc.connect function in code, somewhere else?

my function in controller:

this.connect= function(){              sc.connect(function(response){                  sc.get("/me", function(response){                     // console.log(response);                     var data={};                     data.token = sc.accesstoken();                     data.id = response.id;                     $rootscope.user.sc_id=data.id;                     $rootscope.user.sc_token=data.token;                     soundcloud.savetoken(data);                     soundcloud.generateauthstring();                      //other things          });     });   } 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -