javascript - Facebook JS SDK returning 'unknown' when expecting 'not_authorized' -
i'm having trouble detecting when user has authenticated fb, clicked 'cancel' when asked permissions.
what's happening is:
1) application loads , checks login status... user 'unknown'. great.
2) user clicks "sign in" button calls fb.login() permissions birthdate , address. user shown fb login dialog, enters credentials, , taken permissions dialog.
3) decide cancel. dialog closes , returns status of 'unknown'.
4) refresh page, status check runs again, user 'not_authorized'.
i'm assuming means login portion @ step 2 successful because can open tab fb , user logged in. makes sense since user able login , see permissions dialog, when cancelled, why did remain 'unknown' when in fact are known fb @ point?
i tried add getloginstatus follows:
var login = function(){ console.log('logging in user via fb...'); var dfr = $q.defer(); fb.login(function(response){ if(response.status == 'connected'){ console.log(' user connected'); } if(response.status == 'not_authorized'){ console.log(' user not authorized'); } if(response.status == 'unknown'){ console.log(' user unknown'); // if user unknown, check unknown fb.getloginstatus(function(response){ console.log('status response', response); }); } status.fbuser = response.status; dfr.resolve(response); },{ scope: 'email,public_profile,user_birthday', return_scopes: true }); return dfr.promise; };
... tells me fb still claims not know user. when refresh page, bam! initial login check says user not_authorized. children losing specialness grow adults, when user go unknown not-so-unknown?
i intending on redirecting user either permissions explanation page, or registration page or something, if come login process 'not_authorized'. @ least tells me fb knows person, have not authorized app account, can handle separately unknown.
how return 'not_authorized' without having refresh page? user, fb perspective, 'unknown' or 'not_authorized' @ point between steps 2 , 3?
this answer question leads me consider subscribing fb events detect change, have thought closing dialog, getloginstatus() , events same thing @ point. i'll have try out , report back.
this post close, deals 2 users , new 1 getting replaced old one. i'm talking 1 user changing state.
this post close, fix not authorized. i'm talking unknown user becomes partially connected (i.e. not_authorized) during login process, without requiring page refresh.
there few more posts, i'm hoping makes enough sense differentiate i've read.
Comments
Post a Comment