title: What should the Soundcloud redirect_uri be if I am running my grunt local server?
body: <p>I am just getting started with Soundcloud API and I got snagged on authentication. I have built my AngularJS project with Yeoman and use <code>grunt server</code> to preview my project in the browser at</p>
  <p><code>http://localhost:9000/#/</code></p>
  <p>That is the URL for the <code>index.html</code> which is the main page of my AngularJS app. I have added the following <code>callback.html</code> file (<a href="http://developers.soundcloud.com/docs/api/sdks#javascript" rel="nofollow noreferrer">found here at Soundcloud API docs</a>)</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
    &lt;head&gt;&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
      &lt;title&gt;Connect with SoundCloud&lt;/title&gt;
    &lt;/head&gt;
    &lt;body onload=&quot;window.opener.setTimeout(window.opener.SC.connectCallback, 1)&quot;&gt;
      &lt;b style=&quot;width: 100%; text-align: center;&quot;&gt;This popup should automatically close in a few seconds&lt;/b&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>in my project's <code>app</code> directory which is where the <code>index.html</code> file is located. Additionally and in irrational desperation, I have configured my AngularJS app to serve the <code>callback.html</code> file as a view at the URL</p>
  <p><code>http://localhost:9000/#/callback</code></p>
  <p>I thought maybe it would find it that way. I am starting to think the <code>redirect_uri</code> has to be hosted on an actual server. I am not sure if the grunt's server qualifies as a server that can serve files anywhere but locally.</p>
  <p><strong>Any ideas on what my</strong> <code>redirect_uri</code> <strong>would look like knowing that my</strong> <code>callback.html</code> <strong>file is located in the</strong> <code>app</code> <strong>directory of my AngularJS app?</strong></p>
  <h2>UPDATE 1</h2>
  <p>I have tried different URL/URI combinations.</p>
  <p><strong>Combo 1</strong></p>
  <p>in my Javascript:</p>
  <pre><code>redirect_uri: &quot;http://localhost:9000/#/callback&quot;
  </code></pre>
  <p>in my app settings</p>
  <pre><code>http://localhost:9000/#/callback.html
  </code></pre>
  <p><strong>Combo 2</strong></p>
  <p>in my Javascript:</p>
  <pre><code>redirect_uri: &quot;http://localhost:9000/#/callback.html&quot;
  </code></pre>
  <p>in my app settings</p>
  <pre><code>http://localhost:9000/#/callback.html
  </code></pre>
  <p><strong>Combo 3</strong></p>
  <p>in my Javascript:</p>
  <pre><code>redirect_uri: &quot;http://localhost:9000/#/callback.html&quot;
  </code></pre>
  <p>in my app settings</p>
  <pre><code>http://localhost:9000/#/callback
  </code></pre>
  <p>Additionally when I run this in Chrome I see this error show up in the console in Chrome Dev Tools:</p>
  <pre><code>Uncaught SyntaxError: Unexpected identifier           useranalyzr.js:4
  </code></pre>
  <p>As you can see in my <code>useranalyzr.js</code> file the 4th line is the <code>redirect_uri</code>.</p>
  <pre><code>window.onload = function() {
    SC.initialize({
      client_id: '###################################'
      redirect_uri: &quot;http://localhost:9000/#/callback.html&quot;
    });
  
    SC.connect(function(){
      SC.put(&quot;/me/followings/12345&quot;, function(user, error) {
        if(error){
          alert(&quot;Error: &quot; + error.message);
        }else{
          alert(&quot;You are now following &quot; + user.username);
        }
      });
    });
  }
   
  </code></pre>
  <p>So yeah, no matter what combination I try I always get the same error. I am starting to think that I need to just find a way to get grunt to serve the static callback.html file with out the AngularJS routes getting in the way. Just the direct link.</p>
  <h2>UPDATE 2</h2>
  <p>Ok I am able to serve up <code>callback.html</code> at <code>http://localhost:9000/callback.html</code> and the whole SC.connect authorization process begins. My browser gets redirected to</p>
  <pre><code>https://soundcloud.com/connect?state=SoundCloud_Dialog_c3241&amp;client_id=########‌​############################&amp;redirect_uri=http%3A%2F%2Flocalhost%3A9000%2Fcallbac‌​k.html&amp;response_type=code_and_token&amp;scope=non-expiring&amp;display=popup
  </code></pre>
  <p>I then press connect to authorize access and then the browser redirects to the <code>callback.html</code> located at <code>http://localhost:9000/callback.html</code> but with a code, state and access token attached to it like so</p>
  <pre><code>http://localhost:9000/callback.html?code=508aa0dd5ce3d0f4254157a487fc4826&amp;st‌​ate=SoundCloud_Dialog_c3241#access_token=1-46482-7907892-1328d9e0fc383baf&amp;scope=n‌​on-expiring 
  </code></pre>
  <p>Once that page loads I see an error in the Dev Tools console show up</p>
  <pre><code>Uncaught TypeError: Cannot read property 'SC' of null 
  </code></pre>
  <p>Is that normal?</p>
  <p>Also, I don't want the app to be redirected back to the <code>callback.html</code> at <code>http://localhost:9000/callback.html</code> since my app is based around my <code>index.html</code>, or the <code>http://localhost:9000/#/</code> URL. <strong>How do I make it go back to</strong> <code>http://localhost:9000/#/</code><strong>?</strong></p>
  <p>I started thinking maybe it's because it does not have access to the SoundCloud SDK so I put in</p>
  <pre><code>&lt;script src=&quot;http://connect.soundcloud.com/sdk.js&quot;&gt;&lt;/script&gt;
  </code></pre>
  <p>in the <code>&lt;head&gt;</code> of <code>callback.html</code> but the error persists.</p>
  <h2>UPDATE 3 : UPDATE 2 Issue Solved</h2>
  <p>So I tried it in Firefox and it worked fine. A pop up actually popped up asking me to sign in/connect. After doing so my callback.html was called in the pop up window and then it disappeared all as expected. My main app window remained but with user authentication. The reason it was not working in Chrome was because the pop up was being blocked silently the whole time so Chrome would actually leave my app, go to the sign in/connect page, after I press connect it would go to <code>callback.html</code>. I guess because it was a window tab it would disappear like the code instructed it to. Sorry for my bad explanation. Still a beginner to JS and SC API.</p>