Note that there are some explanatory texts on larger screens.

plurals
  1. POFacebook access token only valid for user that created the facebook application
    primarykey
    data
    text
    <p>I have some JavaScript that logs in a Facebook user and saves the access token to a database:</p> <pre><code>window.fbAsyncInit = function () { FB.init({ appId: '&lt;%=FaceBookApplicationId() %&gt;', status: false, // check login status cookie: true, oauth: true }); }; function facebookLogin() { FB.login(function(response) { if (response.authResponse) { __doPostBack('__Page', 'FacebookDeliveryButton: ' + JSON.stringify(response.authResponse)); } else { console.log('User cancelled login or did not fully authorize.'); } }, { scope: 'offline_access,read_stream,publish_stream,user_photos' }); } </code></pre> <p>A button click fires facebookLogin() which logs in a facebook user, getting a facebook session that includes an access token, which I JSON serialize and post to the server. The server then saves this access token to the database table FacebookDeliveryQueue.</p> <p>I have a Windows service running that periodically queries the FacebookDeliveryQueue table and attempts to post on a user's wall using the access token we saved earlier:</p> <pre><code>IQueryable&lt;FacebookDeliveryQueue&gt; toSend = objectContext.FacebookDeliveryQueues.Where(p =&gt; !p.IsDelivered); foreach (FacebookDeliveryQueue facebookDeliveryQueueItem in toSend) { string facebookAccessToken = facebookDeliveryQueueItem.Cart.FacebookAccessToken; string facebookRecipientId = facebookDeliveryQueueItem.Cart.FacebookRecipientId; var client = new FacebookClient(facebookAccessToken); dynamic parameters = new ExpandoObject(); parameters.message = facebookDeliveryQueueItem.Cart.CustomMessageBody; client.Post(facebookRecipientId + "/feed", parameters); } </code></pre> <p>My problem is, this ONLY works with access tokens from the user that created the facebook application. E.g. </p> <p>Success: I, the creator of this application, log in and pick one of my friends to send a message to, this info is saved to the database, the service runs, my message is posted to my friend's wall. </p> <p>Failure: I log in on my dummy test account (approving the app permissions on this account), pick one of my dummy test account's friend, this info is saved to the database, the service runs and throws an invalid access token error.</p> <p>Any ideas why? </p> <p>Update: Switched to Oauth login -- no change. Still getting "(OAuthException) Invalid access token signature." when attempting to post to friend's wall.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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