Denied email permission with Facebook authentication through Owin -


how re-ask user accept email permission after denied?

my code is:

startup.auth.cs

app.useexternalsignincookie(defaultauthenticationtypes.externalcookie);  var facebookoptions = new facebookauthenticationoptions {     appid = "0000",     appsecret = "0000",     backchannelhttphandler = new facebookbackchannelhandler(),     userinformationendpoint = "https://graph.facebook.com/v2.4/me?fields=id,name,email,first_name,last_name,location",     provider = new facebookauthenticationprovider     {         onauthenticated = context =>         {             context.identity.addclaim(new system.security.claims.claim("facebookaccesstoken", context.accesstoken));             return task.fromresult(true);         }     } }; facebookoptions.scope.add("email"); app.usefacebookauthentication(facebookoptions); 

using helper class extract info need:

/* have taken validation , error handling out */ public static class externallogin {     public static externallogininfo get(iowincontext context)     {             var auth = context.authentication;         var logininfo = auth.getexternallogininfo();         var identityinfo = auth.getexternalidentity(defaultauthenticationtypes.externalcookie);                return new externallogininfo {              email = logininfo.email            ,name = logininfo.externalidentity.name             ,provider = logininfo.login.loginprovider            ,user_access_token = identityinfo.findfirstvalue("facebookaccesstoken")         };     } }  public class externallogininfo {     public string email { get; set; }     public string name { get; set; }         public string provider { get; set; }     public string user_access_token { get; set; } } 

when user denies email permission email set null.

oauthcontroller.cs

  public actionresult callback()         {                       var logininfo = externallogin.get(httpcontext.getowincontext());              /* user denied permission, ask again */             if(string.isnullorempty(logininfo.email))             {                 /* here can display message helps                     user understand  why need hers/his email                     , ask accept permission */              return view("need_your_email_dude");             }            ... 

but how trigger permission form again need_your_email_dude view?


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -