Call a Function Handler after Owin Token Authorization in C# -
i use owin on serverside access token. afterwards, send token client server authenticated. want know, how can run function after authorization completed? (i've tried accesstokenprovider -> onreceiveasync didn't not worked properly).
i found answer. it's enough using onreceive instead of onreceiveasync in app start or initiate oauth object, below:
oauthoptions = new oauthauthorizationserveroptions { tokenendpointpath = new pathstring("/getauthtoken", provider = new applicationoauthprovider(publicclientid, usermanagerfactory), authorizeendpointpath = new pathstring("/api/account/externallogin", accesstokenexpiretimespan = timespan.fromdays(10), allowinsecurehttp = true, accesstokenprovider = new authenticationtokenprovider() { onreceive = context => { context.deserializeticket(context.token); // after can sure ticket initialized , have // access user if(context.ticket.identity.isauthenticated) entitycontext.userid = context.ticket.identity.getuserid(); else entitycontext.userid = ""; } } };
Comments
Post a Comment