Messenger account linking authentication flow in Django
<p>How can I complete the authentication flow of the account linking in Django?</p>

<p>I send the login template to user. When the user clicks on it, she is redirect to <a href="https://example.ngork.io/authenticate" rel="nofollow">https://example.ngork.io/authenticate</a> with the parameters account_linking_token and redirect_uri. </p>

<p>Now, when I perform the redirection I have this error:</p>

<p>Page not found (404)</p>

<p>Request URL:    <a href="http://example.ngrok.io/[redirect_uri]" rel="nofollow">http://example.ngrok.io/[redirect_uri]</a></p>

<ol>
<li>^admin/</li>
<li>^$ [name='index']</li>
<li>^messengerhook [name='messengerhook']</li>
<li>^authenticate [name='authenticate']</li>
</ol>

<p>The current URL didn't march any of these.</p>

<p>EDIT:</p>

<p>the url of the server is generated by ngork since I run it in local. </p>

<pre><code>https://a0505537.ngrok.io
</code></pre>

<p>The redirect uri is the one provided by facebook for linking account flow:</p>

<pre><code>https://www.facebook.com/messenger_platform/account_linking
      ?account_linking_token=ACCOUNT_LINKING_TOKEN
      &amp;authorization_code=AUTHORIZATION_CODE
</code></pre>

<p>About the views, in the question there are the urls written in my urls.py setting file.</p>

<p>Basically, the authenticate view is a login button and when the user is logged I run <code>window.location.replace(["redirect_uri"])</code></p>

<p>RESOLVED:</p>

<p>The url wasn't decoded, so I add:</p>

<pre><code>var url = decodeURIComponent(params["redirect_uri"]);
</code></pre>

<p>I resolved the issue. Details are in the question after the tag RESOLVED</p>

python django facebook bots facebook-messenger