angularjs - What should the Soundcloud redirect_uri be if I am running my grunt local server? -


i getting started soundcloud api , got snagged on authentication. have built angularjs project yeoman , use grunt server preview project in browser @

http://localhost:9000/#/

that url index.html main page of angularjs app. have added following callback.html file (found here @ soundcloud api docs)

<!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 project's app directory index.html file located. additionally , in irrational desperation, have configured angularjs app serve callback.html file view @ url

http://localhost:9000/#/callback

i thought maybe find way. starting think redirect_uri has hosted on actual server. not sure if grunt's server qualifies server can serve files anywhere locally.

any ideas on my redirect_uri would knowing my callback.html file located in the app directory of angularjs app?

update 1

i have tried different url/uri combinations.

combo 1

in javascript:

redirect_uri: "http://localhost:9000/#/callback" 

in app settings

http://localhost:9000/#/callback.html 

combo 2

in javascript:

redirect_uri: "http://localhost:9000/#/callback.html" 

in app settings

http://localhost:9000/#/callback.html 

combo 3

in javascript:

redirect_uri: "http://localhost:9000/#/callback.html" 

in app settings

http://localhost:9000/#/callback 

additionally when run in chrome see error show in console in chrome dev tools:

uncaught syntaxerror: unexpected identifier           useranalyzr.js:4 

as can see in useranalyzr.js file 4th line redirect_uri.

window.onload = function() {   sc.initialize({     client_id: '###################################'     redirect_uri: "http://localhost:9000/#/callback.html"   });    sc.connect(function(){     sc.put("/me/followings/12345", function(user, error) {       if(error){         alert("error: " + error.message);       }else{         alert("you following " + user.username);       }     });   }); } 

so yeah, no matter combination try same error. starting think need find way grunt serve static callback.html file out angularjs routes getting in way. direct link.

update 2

ok able serve callback.html @ http://localhost:9000/callback.html , whole sc.connect authorization process begins. browser gets redirected

https://soundcloud.com/connect?state=soundcloud_dialog_c3241&client_id=########‌​############################&redirect_uri=http%3a%2f%2flocalhost%3a9000%2fcallbac‌​k.html&response_type=code_and_token&scope=non-expiring&display=popup 

i press connect authorize access , browser redirects callback.html located @ http://localhost:9000/callback.html code, state , access token attached

http://localhost:9000/callback.html?code=508aa0dd5ce3d0f4254157a487fc4826&st‌​ate=soundcloud_dialog_c3241#access_token=1-46482-7907892-1328d9e0fc383baf&scope=n‌​on-expiring  

once page loads see error in dev tools console show up

uncaught typeerror: cannot read property 'sc' of null  

is normal?

also, don't want app redirected callback.html @ http://localhost:9000/callback.html since app based around index.html, or http://localhost:9000/#/ url. how make go to http://localhost:9000/#/?

i started thinking maybe it's because not have access soundcloud sdk put in

<script src="http://connect.soundcloud.com/sdk.js"></script> 

in <head> of callback.html error persists.

update 3 : update 2 issue solved

so tried in firefox , worked fine. pop popped asking me sign in/connect. after doing callback.html called in pop window , disappeared expected. main app window remained user authentication. reason not working in chrome because pop being blocked silently whole time chrome leave app, go sign in/connect page, after press connect go callback.html. guess because window tab disappear code instructed to. sorry bad explanation. still beginner js , sc api.

for callback uri, need match app settings page. using # in uri won't work, redirect_uri file needs have call window.opener.sc.connectcallback, doesn't need part of js app structure.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -