.net - IXXXOAuth2AuthenticationProvider Authenticated called but User is always null -
good day.
im having trouble oauth. have code users works , others doesn't. me depends on browser, chrome+firefox works, while ie edge doesn't - no errors, no exceptions.
this piece of code:
appbuilder.usefacebookauthentication(new facebookauthenticationoptions { appid = cfgreader.facebookappid, appsecret = cfgreader.facebookappsecret, scope = { "email" }, signinasauthenticationtype = constantstrings.authorizationcookiename, backchannelhttphandler = new facebookbackchannelhandler(), userinformationendpoint = "https://graph.facebook.com/v2.4/me?fields=id,name,email", provider = new facebookauthenticationprovider { onauthenticated = (context) => { context.identity.addclaim(new system.security.claims.claim("facebookaccesstoken", context.accesstoken)); foreach (var claim in context.user) { var claimtype = string.format("urn:facebook:{0}", claim.key); string claimvalue = claim.value.tostring(); if (!context.identity.hasclaim(claimtype, claimvalue)) { context.identity.addclaim(new system.security.claims.claim(claimtype, claimvalue, "xmlschemastring", "facebook")); } } return task.fromresult(0); } } });
should make application able login user , read 1 name , email. , works on machine , ff/chrome. when run on edge fails. failing part not here, in part:
var manager = this.httpcontext.getowincontext().authentication; authenticateresult result = await manager.authenticateasync(constantstrings.authorizationcookiename).withcurrentculture<authenticateresult>();
problem user in manager null. if put breakpoint in authenticated event i'm able read data authenticated user. somewhere i'm being nulled have no idea why , where. same goes google authentication, practically identical code authenticated, similar use case: on authenticated full user data next user null.
any advice appreciated.
Comments
Post a Comment