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

Facebook login returning "unauthorized"

Open chuckurbis opened this issue 10 years ago • 22 comments

I've been trying to hook up Facebook login via an iPhone app. I have set the FACEBOOK_APP_ID on my Heroku deploy and even echoing it out to the log so I know that is being set.

My iPhone app has all there correct information in the plist file.

For some reason though, when I go through the connect process using, PFFacebookUtils.logInInBackgroundWithReadPermissions, the app always returns:

unauthorized (Code: 0, Version: 1.12.0)

I'm not sure where to begin tracking this error down. I don't see anything in the log files either.

Any help would be greatly appreciated. Thank you.

chuckurbis avatar Feb 04 '16 21:02 chuckurbis

Did you set the facebookAppIds in the parse-server? Related to #82

francocorreasosa avatar Feb 04 '16 23:02 francocorreasosa

No, I haven't. Is that part of the

var api = new ParseServer({
   ...
});

Code? I didn't see that in the docs. IS that now the official way to do it and if so do i still need to set the env var FACEBOOK_APP_ID?

Thank you.

chuckurbis avatar Feb 04 '16 23:02 chuckurbis

It is in the readme, you can pass in an array of facebook app ids: https://github.com/ParsePlatform/parse-server/blob/master/README.md

You no longer need to set the environment variable.

Let me know if you have any other issues!

gfosco avatar Feb 04 '16 23:02 gfosco

I'm actually still seeing the issue. This is what my code looks like

var api = new ParseServer({
  databaseURI: databaseUri ,
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || '...',
  masterKey: process.env.MASTER_KEY || '...',
  clientKey: '...', 
  javascriptKey: '...',
  facebookAppIds: ['1677777875569507']
});

Is there something I'm missing with that?

chuckurbis avatar Feb 05 '16 00:02 chuckurbis

I'm still experiencing the same issue with Facebook login.

var api = new ParseServer({
    databaseURI     : "...",
    cloud           : "...",
    appId           : "...",
    masterKey       : "...",
    facebookAppIds  : ["742406752547323"],
    filesAdapter    : new S3Adapter(
        "...",
        ".../",
        {
            bucket          : "...",
            bucketPrefix    : "files/",
            directAccess    : true
        }
    )
});

nathan-charles avatar Feb 05 '16 03:02 nathan-charles

Figured out a why this was still not working. If I called Parse.setApplicationId and Parse.initializeWithConfiguration this error would still happen. Also note that if you use the local datastore, that needs to be set in the configuration block as well.

chuckurbis avatar Feb 05 '16 21:02 chuckurbis

I'm not calling Parse.setApplicationId in my code it has been commented out since I migrated. I'm getting the following error.

Permission denied for this action. (Code: 101, Version: 1.12.0)

nathan-charles avatar Feb 05 '16 23:02 nathan-charles

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 validateAuthData.

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

cc @flovilmart

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

@penultimate-labs you're definitely right! The validateAppId should match the mockFacebook() in the test suite.

flovilmart avatar Feb 18 '16 13:02 flovilmart

@chuckurbis Can you share me how to fix this?

tran-huy-phuc avatar Mar 04 '16 03:03 tran-huy-phuc

has this issue been resolved? On my iOS and Android still experiences this while JS app is working fine. On iOs: Permission denied for this action." UserInfo={code=101, temporary=0, error=Permission denied for this action., NSLocalizedDescription=Permission denied for this action.})

tobernguyen avatar Mar 14 '16 04:03 tobernguyen

Did you update to the latest version?

flovilmart avatar Mar 14 '16 15:03 flovilmart

Yes I did. Now I'm using [email protected]

tobernguyen avatar Mar 14 '16 16:03 tobernguyen

Then Permission denied for this action is a Class Level Permission error. Did you set any CLP on _User? Can you provide the logs your get when running in VERBOSE=1.

Also, what version of Parse/FBSDK are you running on iOS?

flovilmart avatar Mar 14 '16 16:03 flovilmart

My CLP on _User screen shot 2016-03-14 at 11 49 38 pm

Btw, I'm doing test with VERBOSE=1, will update when ready.

tobernguyen avatar Mar 14 '16 16:03 tobernguyen

This would be the addField permission that would block I believe. Can you try turning it ON an see if the request passes?

flovilmart avatar Mar 14 '16 17:03 flovilmart

@flovilmart awesome! It works flawlessly. Thanks so much! Do you still need the log when running in VERBOSE=1?

tobernguyen avatar Mar 14 '16 17:03 tobernguyen

I'd like to understand why it blocked you from linking the user, did you add extra fields to the user object before linking?

flovilmart avatar Mar 14 '16 17:03 flovilmart

I do nothing on client side but I have the hook afterSave on _User on cloud code. I add some fields to new User only. But the weird thing is that I couldn't log in as a new user as well as existed user.

tobernguyen avatar Mar 14 '16 17:03 tobernguyen