0

I'm trying to set up a chrome extension that uses a Facebook Access token to login to Parse using the JS api. As a proof of concept I tried following the example here with curl, but when I put in my access_token and expiration_date, the POST call returns {"code":251,"error":"Parse::InvalidSessionError"}

Specifically, I'm calling this from the OSX shell.

curl -X POST

-H "X-Parse-Application-Id: [my app id]" \
-H "X-Parse-REST-API-Key: [my rest api key]" \
-H "X-Parse-Revocable-Session: 1" \
-H "Content-Type: application/json" \
-d '{
      "authData": {
        "facebook": {
          "id": "[my id as a string]",
          "access_token": "[my token as a string]",
          "expiration_date": "2015-10-26T07:45:16.579Z"
        }
      }
    }' \
https://api.parse.com/1/users

I've googled around a bit, including reading the following posts, but after changing my settings on my Facebook app multiple times and re-authenticating, it is still throwing the same error.

Using FB user to login on parse. Error code: 251, Invalid Sesion Error

Parse Facebook login fails with error code 251

For the record, I've tried changing my "App Secret embedded in the client" Facebook setting to false, as well as my "Native or desktop app?" to both yes and no (I'm fairly sure it should be set to yes, as I'm using the desktop app FB login flow.) I've also added my facebook app to my parse app, and enabled Facebook integration on parse, as well as double checking my parse app and rest api keys.

Please let me know what else I should try, or what other information you need to assess this.

Community
  • 1
  • 1

1 Answers1

1

Two things were wrong with the way I was approaching this.

  1. I was creating the "Expires_at" field by adding the "Expires_in" field (returned using this FB login flow) to the current time as calculated by my browser. In retrospect this was silly, as the expiration time is supposed to be exact, and network latency will change the calculated time by a bit.

  2. I was using the wrong facebook ID for my request - there are two types of IDs now, and you need to use the correct one. See this link..