Return User to login page, if user doesn't "Allow" facebook permissions in ASP.NET Core application

Hi, I have created an app at Facebook developer page and configured that with my Identity server application URL. Identity server4 application is built in core.

When user enter the website and tries to connect it using his/her Facebook account, then my app created under Facebook developer ask him the permission to allow the app to receive her information like email adress, age, etc, when user cancelled the permission he is redirected to page "Account/Login" I have followed the steps in this link :



But when user accept the permissions, our app ask him for another permissions (permission for managing her pages facebook "manage_page") :

here if the user decline the permissions he will redirect to Account/ExternalLoginCallback. 

Actually, I need the permission from the user to collect the data from their pages, so they need to give me the authrise to access their pages. Otherwise, we will have no data to give them. So we will redirect them to start point Account/Login means if the user accept the first permission getting the information public email , profile and decline the permissions of "manage_page" they should be forced to redirect to the starting page of app, thet is, "Account/Login"

How I can do that? Thanks.

Asked by:- LuneAgile
: 231 At:- 12/11/2018 12:46:01 PM facebook-permissions

1 Answers
profileImage Answered by:- Sam

Why don't you divide the steps in two process.

  1. First, ask the user to login using their Facebook credentials.
  2. Once the user is logged in the show some page in your application "/Account/GetPageAccess"
  3. Now ask them to provide access to their pages, if they decline, you must get some error from facebook, if that happens show dialog box saying "Need facebook pages access to show you some data"

You can grab the declined permissions using JS code as below

FB.api('/me/permissions', function(response) {
  var declined = [];
  for (i = 0; i <; i++) { 
    if ([i].status == 'declined') {

or using API URL and access token:

You can also re-ask user for permissions, take a look at these URL

That's it.



At:- 12/13/2018 4:14:21 PM

Login/Register to answer
Register directly by posting answer/details

Full Name *

Email *

By posting your answer you agree on privacy policy & terms of use