parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Facebook Auth: Error 101 "Facebook auth is invalid for this user"

Open penultimate-labs opened this issue 10 years ago • 43 comments

I believe there's a bug in 2.1.0 with the RestWrite.js -> facebook.js data path. The validateAppId function in facebook.js assumes a passing of the literal access_token (String) but what's actually passed is an authData structure within which lives a key called "access_token".. so facebook.js should actually be trying to append access_token.access_token to the graph request, and not just access_token. More appropriately, the access_token argument of facebook.js:validateAppId should be renamed to authData and subsequently authData.access_token for the string builder contained within. As it is for the validateAuthData function above it.

penultimate-labs avatar Feb 18 '16 05:02 penultimate-labs

Ok, this is still an issue. There are two facebook.js files, one in oauth and one in the general /lib folder . The one in oauth reflects this problem, and at least on my local deployment, is the one being called.

penultimate-labs avatar Feb 18 '16 06:02 penultimate-labs

@flovilmart

nitrag avatar Feb 18 '16 15:02 nitrag

@penultimate-labs @nitrag There is a proposal here #478 Can you check if it reproduces?

flovilmart avatar Feb 18 '16 16:02 flovilmart

#478 should fix this. Please re-open if it doesn't.

drew-gross avatar Feb 18 '16 16:02 drew-gross

still receiving Facebook auth is invalid for this user :/

absolutlabs avatar Feb 18 '16 17:02 absolutlabs

@absolutlabs what version are you using? How is your parse-server configured? Please also consider running the server with VERBOSE=1 so you can provide the trace of network requests.

flovilmart avatar Feb 18 '16 17:02 flovilmart

Hello Thanks for your help

I'm using the parse-server-example on Heroku

package.json :

{
  "name": "parse-server-example",
  "version": "1.0.0",
  "description": "An example Parse API server using the parse-server module",
  "main": "index.js",
  "repository": {
    "type": "git",
    "url": "https://github.com/ParsePlatform/parse-server-example"
  },
  "license": "MIT",
  "dependencies": {
    "express": "~4.2.x",
    "kerberos": "~0.0.x",
    "parse": "~1.6.14",
    "parse-server": "latest"
  },
  "scripts": {
    "start": "node index.js"
  },
  "engines": {
    "node": ">=4.1"
  }
}

node_modules_cache is disabled (heroku config:set NODE_MODULES_CACHE=false, is it correct ?)

index.js :

var api = new ParseServer({
  databaseURI: process.env.DATABASE_URI,
  cloud: __dirname + '/cloud/main.js',
  appId: process.env.APP_ID,
  masterKey: process.env.MASTER_KEY,
  clientKey: process.env.CLIENT_KEY,
  serverURL : 'https://deuxpointzero.herokuapp.com/parse',
  facebookAppIds : '698426340294778',
  oauth : {
   facebook: {
     appIds: '698426340294778'
    }
  }
});

absolutlabs avatar Feb 18 '16 18:02 absolutlabs

@absolutlabs I'm not sure latest would pick the github master version. Could you try replace "parse-server": "latest" by "parse-server": "git://github.com/parseplatform/parse-server#master"

or "parse-server": "parseplatform/parse-server#master" or "parse-server": "parseplatform/parse-server"

For more info on github URL's see here

Also it seems that your parse package version is out of date, please use ~1.7.0

Secondly, are you FacebookAppIds valid and was the auth token acquired with that app ID?

flovilmart avatar Feb 18 '16 18:02 flovilmart

Heroku now fails to launch the app after deploying with one of the parse-server addresses you suggested:

Error: Cannot find module 'parse-server'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/app/index.js:4:19)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)

FacebookAppIds was working great before migrating to heroku + mongolab. Before 2.1.0, login with FB worked but after a fetch on user, token became invalid ( #427 & #373 ) .

Build logs, in case it could help :

remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Using set buildpack heroku/nodejs
remote: -----> Node.js app detected
remote: 
remote: -----> Creating runtime environment
remote:        
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NPM_CONFIG_PRODUCTION=true
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=false
remote: 
remote: -----> Installing binaries
remote:        engines.node (package.json):  >=4.1
remote:        engines.npm (package.json):   unspecified (use default)
remote:        
remote:        Resolving node version >=4.1 via semver.io...
remote:        Downloading and installing node 5.6.0...
remote:        Using default npm version: 3.6.0
remote: 
remote: -----> Restoring cache
remote:        Skipping cache restore (disabled by config)
remote: 
remote: -----> Building dependencies
remote:        Pruning any extraneous modules
remote:        Installing node modules (package.json)
remote:        
remote:        > [email protected] install /tmp/build_3b87c0c6b4e66823ca6f4e355fc1bc30/node_modules/kerberos
remote:        > (node-gyp rebuild) || (exit 0)
remote:        
remote:        make: Entering directory `/tmp/build_3b87c0c6b4e66823ca6f4e355fc1bc30/node_modules/kerberos/build'
remote:        CXX(target) Release/obj.target/kerberos/lib/kerberos.o
remote:        CXX(target) Release/obj.target/kerberos/lib/worker.o
remote:        CC(target) Release/obj.target/kerberos/lib/kerberosgss.o
remote:        ../lib/kerberosgss.c:36:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]
remote:        #pragma clang diagnostic push
remote:        ^
remote:        ../lib/kerberosgss.c:37:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]
remote:        #pragma clang diagnostic ignored "-Wdeprecated-declarations"
remote:        ^
remote:        ../lib/kerberosgss.c: In function ‘authenticate_gss_client_wrap’:
remote:        ../lib/kerberosgss.c:362:19: warning: variable ‘server_conf_flags’ set but not used [-Wunused-but-set-variable]
remote:        char buf[4096], server_conf_flags;
remote:        ^
remote:        ../lib/kerberosgss.c: At top level:
remote:        ../lib/kerberosgss.c:930:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]
remote:        #pragma clang diagnostic pop
remote:        ^
remote:        CC(target) Release/obj.target/kerberos/lib/base64.o
remote:        CXX(target) Release/obj.target/kerberos/lib/kerberos_context.o
remote:        SOLINK_MODULE(target) Release/obj.target/kerberos.node
remote:        COPY Release/kerberos.node
remote:        make: Leaving directory `/tmp/build_3b87c0c6b4e66823ca6f4e355fc1bc30/node_modules/kerberos/build'
remote:        [email protected] /tmp/build_3b87c0c6b4e66823ca6f4e355fc1bc30
remote:        ├─┬ [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ ├── [email protected]
remote:        │ │ └── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ └── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ └── [email protected]
remote:        ├─┬ [email protected]
remote:        │ └── [email protected]
remote:        ├─┬ [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ └── [email protected]
remote:        │ └── [email protected]
remote:        └─┬ [email protected]  (git://github.com/parseplatform/parse-server.git#ba68acfb0d63dd6d101a245926d14cae1c9db1a9)
remote:        ├─┬ [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ └── [email protected]
remote:        │ ├── [email protected]
remote:        │ └── [email protected]
remote:        ├─┬ [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ └─┬ [email protected]
remote:        │   └── [email protected]
remote:        ├── [email protected]
remote:        ├── [email protected]
remote:        ├─┬ [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ ├── [email protected]
remote:        │ │ └── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ └── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ └── [email protected]
remote:        │ └─┬ [email protected]
remote:        │   └── [email protected]
remote:        ├── [email protected]
remote:        ├─┬ [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ └── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ ├── [email protected]
remote:        │ │ └── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ ├── [email protected]
remote:        │ │ └── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ ├── [email protected]
remote:        │ │ └── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ └── [email protected]
remote:        ├── [email protected]
remote:        ├─┬ [email protected]
remote:        │ ├── [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ ├── [email protected]
remote:        │ │ └─┬ [email protected]
remote:        │ │   ├── [email protected]
remote:        │ │   └── [email protected]
remote:        │ └─┬ [email protected]
remote:        │   ├── [email protected]
remote:        │   ├── [email protected]
remote:        │   └── [email protected]
remote:        ├─┬ [email protected]
remote:        │ ├── [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ ├─┬ [email protected]
remote:        │ │ │ ├── [email protected]
remote:        │ │ │ └── [email protected]
remote:        │ │ └── [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ ├─┬ [email protected]
remote:        │ │ │ ├── [email protected]
remote:        │ │ │ └── [email protected]
remote:        │ │ └── [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ └── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ └── [email protected]
remote:        ├─┬ [email protected]
remote:        │ └── [email protected]
remote:        ├─┬ [email protected]
remote:        │ ├── [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ └── [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ └── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ └── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ └── [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ ├─┬ [email protected]
remote:        │ │ │ ├── [email protected]
remote:        │ │ │ ├── [email protected]
remote:        │ │ │ ├─┬ [email protected]
remote:        │ │ │ │ └── [email protected]
remote:        │ │ │ ├── [email protected]
remote:        │ │ │ └── [email protected]
remote:        │ │ ├─┬ [email protected]
remote:        │ │ │ └── [email protected]
remote:        │ │ ├─┬ [email protected]
remote:        │ │ │ ├── [email protected]
remote:        │ │ │ ├─┬ [email protected]
remote:        │ │ │ │ └── [email protected]
remote:        │ │ │ └── [email protected]
remote:        │ │ └─┬ [email protected]
remote:        │ │   └── [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ ├── [email protected]
remote:        │ │ ├── [email protected]
remote:        │ │ ├── [email protected]
remote:        │ │ └── [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ ├── [email protected]
remote:        │ │ ├─┬ [email protected]
remote:        │ │ │ ├── [email protected]
remote:        │ │ │ ├── [email protected]
remote:        │ │ │ └── [email protected]
remote:        │ │ └─┬ [email protected]
remote:        │ │   ├── [email protected]
remote:        │ │   ├─┬ [email protected]
remote:        │ │   │ └── [email protected]
remote:        │ │   ├── [email protected]
remote:        │ │   ├── [email protected]
remote:        │ │   ├── [email protected]
remote:        │ │   └── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├─┬ [email protected]
remote:        │ │ └── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ ├── [email protected]
remote:        │ └── [email protected]
remote:        └─┬ [email protected]
remote:        ├── [email protected]
remote:        ├── [email protected]
remote:        ├── [email protected]
remote:        ├── [email protected]
remote:        ├── [email protected]
remote:        └── [email protected]
remote:        
remote: 
remote: -----> Caching build
remote:        Clearing previous node cache
remote:        Skipping cache save (disabled by config)
remote: 
remote: -----> Build succeeded!
remote:        ├── [email protected]
remote:        ├── [email protected]
remote:        ├── [email protected]
remote:        └── [email protected] (git://github.com/parseplatform/parse-server.git#ba68acfb0d63dd6d101a245926d14cae1c9db1a9)
remote:        
remote: 
remote: -----> Discovering process types
remote:        Procfile declares types     -> (none)
remote:        Default types for buildpack -> web
remote: 
remote: -----> Compressing...
remote:        Done: 17.3M
remote: -----> Launching...
remote:        Released v45
remote:        https://deuxpointzero.herokuapp.com/ deployed to Heroku
remote: 
remote: Verifying deploy.... done.
To https://git.heroku.com/deuxpointzero.git
   ccdbaf6..11f7b2f  master -> master

thanks

absolutlabs avatar Feb 18 '16 18:02 absolutlabs

It seems that npm build is not run upon deployment to generate the lib directory.

flovilmart avatar Feb 18 '16 23:02 flovilmart

Same error with AWS... :(

nitrag avatar Feb 19 '16 03:02 nitrag

@nitrag the Facebook auth error?

flovilmart avatar Feb 19 '16 04:02 flovilmart

No sorry, well, I'm still having that issue too but I am hoping it will be solved with some of the latest commits. I was referring to AWS NodeJS server pulling the absolute latest and greatest from github via your suggestion of putting the url in package.json. It seems that AWS (like Heroku for OP) doesn't support this.

I'll just wait until tomorrow for the next npm release.

On Thu, Feb 18, 2016 at 11:30 PM, Florent Vilmart [email protected] wrote:

@nitrag https://github.com/nitrag the Facebook auth error?

— Reply to this email directly or view it on GitHub https://github.com/ParsePlatform/parse-server/issues/475#issuecomment-186045530 .

nitrag avatar Feb 19 '16 05:02 nitrag

Everything works well with 2.1.2 (session token and FB oauth) Problem solved ! Thanks :)

absolutlabs avatar Feb 23 '16 18:02 absolutlabs

@absolutlabs good to hear! Cheers!

flovilmart avatar Feb 23 '16 18:02 flovilmart

@flovilmart @absolutlabs In my project I'm using parse-server version 2.1.6 and still getting the same error: "Facebook auth is invalid for this user".

Can someone help me to achieve it.

Gegham avatar Mar 15 '16 12:03 Gegham

@Gegham what client are you using?

flovilmart avatar Mar 15 '16 12:03 flovilmart

@flovilmart I'm using parse-server in Node.js

Gegham avatar Mar 15 '16 12:03 Gegham

I mean to log/link your user in? Did you properly configure ParseServer with facebookAppIds as described here?

flovilmart avatar Mar 15 '16 12:03 flovilmart

Oh, I'm using iOS SDK. Yes I've implemented it as described in docs. Please review :

var api = new ParseServer({ databaseURI: 'mongodb://localhost:27017/HelpIn', cloud: 'C:/inetpub/wwwroot/HelpIn/cloud/main.js', // Provide an absolute path appId: AppID, clientKey: ClientPath, masterKey: MasterKey, // Keep this key secret! serverURL: 'http://localhost:1337/parse', // Don't forget to change to https if needed push: { ios: [ { pfx: './Resources/helpin_development_push_certificate.p12', // Dev PFX or P12 bundleId: 'info.way4app.SocialMap', production: false // Dev }, { pfx: './Resources/helpin_distribution_push_certificate.p12', // Prod PFX or P12 bundleId: 'info.way4app.SocialMap',
production: true // Prod } ] }, facebookAppIds : '765363916914088', oauth: { facebook: { appIds: "765363916914088" } } });

Gegham avatar Mar 15 '16 12:03 Gegham