How to make email permission required when logging in/signing up a user using the FB login?
You should check the received Access Token before you continue with your application logic. How to do this is described here:
https://developers.facebook.com/docs/facebook-login/permissions/v2.0#checking
If you then recognize that the User didn't give the email
permission, you can resend him to the permission dialog as described here:
https://developers.facebook.com/docs/facebook-login/permissions/v2.0#handling
Quote:
If someone has declined a permission for your app, the login dialog won't let your app re-request the permission unless you pass
auth_type=rerequest
along with your request.
Jeromie Devera
I'm a beginning PHP programmer. I like to create fun, and useful apps :P
Updated on June 04, 2022Comments
-
Jeromie Devera almost 2 years
I can't seem to make the email permission required.
If a user unticks the email udring the FB login, my code breaks down. And when I try writing code around this problem (try to alert the user to accept the email permission requisite.), it won't work; the user would have to revoke the App's access manually in their FB settings, and that is obviously out of the question.
So how can I make the email permission required as part of my app/website?
Tbh, I couldn't read through the entire Facebook API docs without scratching my head through it.
Here is what I have currently:
var $user = null; function __construct() { //blahblahlblah //blahblahblah (Code needed for facebook login to work) $this->user = $this->facebook->getUser(); if ($this->user) { try { // Proceed knowing you have a logged in user $this->user = $this->facebook->api('/me'); $this->logoutUrl = $this->facebook->getLogoutUrl( array('next' => base_url() . 'connect/logout') ); } catch (FacebookApiException $e) { error_log($e); $this->user = null; } } } function process() { // If the Facebook user allows his/her email to be shared. // [If they don't, skip to the `else` statement below] if (isset($this->user['email'])) { //Great! I can process normally } // If the Facebook user doesn't share their email. else { //What do I do here? //I'm not sure how the OAuth works, so that's why im checking echo 'email is required. line 86 , connect.php controller'; } }
-
Macerier almost 10 yearsthen the user can't login to your app. and cantspan policy prevents you from forcing user to give you his email.
-
Tobi almost 10 yearsTo request the permission wasn't his problem,a s he wrote. He wants to know a solution on how to handle missing permissions!
-
Jeromie Devera almost 10 yearsYou see, that is what I've been reading, but [sorry for my lack of understanding fb api docs] how could I do that via my server? I edited my question with some code above.