title: Facebook login with redirect URL
body: <p>I am developing a Facebook canvas appliaction, and I am trying to do the following, which is standard in many applications.</p>
  
  <ul>
  <li>User arrives on my application page.</li>
  <li>If he has not granted the necessary permissions, he is redirected to a page where he can (optionally authenticate) and accept the permissions, and</li>
  <li>finally redirected back to my facebook application page.</li>
  </ul>
  
  <p>As far as I understand, this is achieved by redirecting the user to the <a href="http://developers.facebook.com/docs/reference/dialogs/oauth/" rel="nofollow">OAuth dialog</a>, on</p>
  
  <pre><code>http://www.facebook.com/dialog/oauth/?
    scope=PERMISSIONS&amp;
    client_id=CLIENT_ID&amp;
    redirect_uri=MY_CANVAS_URL&amp;
    response_type=token
  </code></pre>
  
  <p>The problem is that Facebook will not allow a redirect from inside an iframe, for security reasons. It only allows redirects to what I declare as <code>site URL</code> on the application settings page. In my case I have set that to the URL of the application on Facebook, since that is what I put as <code>redirect_uri</code> (and it works).</p>
  
  <p>So, instead of being able to see the authentication dialog, the user is presented only a link to it. A kind of workaround is to issue the redirect with javascript, by manually settings <code>top.location</code>. But this is not a real solution, since part of the site already shows before Javascript redirects, and I get an annoying flicker.</p>
  
  <blockquote>
    <p>What is the correct way to obtain this flow?</p>
  </blockquote>