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 asp.net 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 : https://qawithexperts.com/questions/387/access-denied-when-permission-of-app-to-my-application-is-de

qa2-min.png

 

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
0
: 4048 At:- 12/11/2018 12:46:01 PM
asp.net asp.net-core 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 < response.data.length; i++) { 
    if (response.data[i].status == 'declined') {
      declined.push(response.data[i].permission)
    }
  }
  alert(declined.toString())
});

https://developers.facebook.com/docs/facebook-login/handling-declined-permissions/#reprompt

or using API URL and access token: https://graph.facebook.com/me/permissions?access_token=USER_ACCESS_TOKEN

You can also re-ask user for permissions, take a look at these URL https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/#reaskperms

https://stackoverflow.com/questions/28621606/asp-net-identity-facebook-login-pass-in-rerequest/41975557#41975557

That's it.

 

 

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






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

Full Name *

Email *




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