c# - AuthenticationTokenReceiveContext can't access token value in Owin.Security / Identity Framework upon token refresh -
in .net project identity framework can't renew tokens, though can generate one. exception follows:
[argumentnullexception: value cannot null. parameter name: token] microsoft.owin.security.infrastructure.authenticationtokenreceivecontext..ctor(iowincontext context, isecuredataformat`1 securedataformat, string token) +136 microsoft.owin.security.oauth.<invoketokenendpointrefreshtokengrantasync>d__44.movenext() +158 system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) +99 system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) +58 system.runtime.compilerservices.taskawaiter.validateend(task task) +25 microsoft.owin.security.oauth.<invoketokenendpointasync>d__1e.movenext() +2159
due exception, debugger won't step token refreshing function:
public async task receiveasync(authenticationtokenreceivecontext context) { var allowedorigin = context.owincontext.get<string>("as:clientallowedorigin"); context.owincontext.response.headers.add("access-control-allow-origin", new[] { allowedorigin }); string hashedtokenid = helper.gethash(context.token); using (authrepository _repo = new authrepository()) { var refreshtoken = await _repo.findrefreshtoken(hashedtokenid); if (refreshtoken != null ) { //get protectedticket refreshtoken class context.deserializeticket(refreshtoken.protectedticket); var result = await _repo.removerefreshtoken(hashedtokenid); } } }
i'm debugging using postman, , request posted contain proper token, isn't detected in request body, neither in request header.
katana dev team has marked bug: http://katanaproject.codeplex.com/workitem/480 stated no updates coming.
the same codebase runs on remote server: http://ngauthenticationweb.azurewebsites.net/
complete project in can reproduced available at: https://github.com/tjoudeh/angularjsauthentication
how force token context, prevent exception?
could check grant_type , client_id in postman? grant_type should 'password'.
sample: username=abcd&password=abc@123&grant_type=password&client_id=c4b2f91dbe014b558d7fa00ca54ed33d
Comments
Post a Comment