Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I reuse my server-side Facebook access_token in javascript SDK?
    text
    copied!<p><strong>Scenario/setup</strong></p> <p>I have a web application that allows a user to log in using either Facebook or username+password. The user is able to link Facebook to the account, in which case the backend stores an offline Facebook access_token token, so that it can make various requests. This all works fine.</p> <p>Now I want to use features of the Facebook Javascript SDK (specifically open the requests dialog), but I do not want the user to be forced to log into Facebook on the client if he just logged into the application using username/password.</p> <p><strong>Question</strong></p> <p>Having a valid access_token on the server, I want to pass this token to the Facebook javascript SDK, so that no matter how the user logged into my web application, he is now "logged in" to the Facebook account associated with his account, as far as the SDK is concerned.</p> <p>I have found a few vague examples, but none that explain in detail how to do it entirely.</p> <p>Currently I am thinking the way to go is passing the token to javascript in FB.Init, but I cannot get it to work:</p> <pre><code>FB.Init({ authResponse: { access_token: &lt;token&gt;, expiresIn: &lt;expiry&gt;, signedRequest: &lt;what-is-this?&gt;, userID: &lt;user&gt; }, ... }); </code></pre> <p>Another example I found, passed the access_token directly to the API call, but this does not seem to work either:</p> <p><code>FB.ui({ method: 'apprequests', access_token: &lt;token&gt;, ... ();</code></p> <p>Any ideas?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload