c# - Invalid JWT token when using bootstrapContext.Token after solution rebuild -
i need add users toekn authenticationcontext tokencache when rebuild app in visual studio, or (in live) iis reset.
i have below code runs fine after log in using azure active directory
authenticationcontext authcontext = new authenticationcontext(startup.authority); var bootstrapcontext = claimsprincipal.current.identities.first().bootstrapcontext system.identitymodel.tokens.bootstrapcontext; string username = claimsprincipal.current.findfirst(claimtypes.upn) != null ? claimsprincipal.current.findfirst(claimtypes.upn).value : claimsprincipal.current.findfirst(claimtypes.email).value; userassertion ua = new userassertion(bootstrapcontext.token, "urn:ietf:params:oauth:grant-type:jwt-bearer", username); var renewcache = await authcontext.acquiretokenasync(apiconstants.aad_audience, apiconstants.aad_webclientid, ua); once rebuild solution , run same web request below error though bootstrapcontext.token same.
system.exception: {"error":"invalid_request","error_description":"aadsts50027: invalid jwt token. aadsts50027: invalid jwt token. token format not valid.\r\ntrace id: 92c0f00e-e7a2-4d8a-a1fc-ddd7a448cb96\r\ncorrelation id: 9c267328-7772-41de-bf77-745a23318adc\r\ntimestamp: 2016-11-11 03:55:00z","error_codes":[50027,50027],"timestamp":"2016-11-11 03:55:00z","trace_id":"92c0f00e-e7a2-4d8a-a1fc-ddd7a448cb96","correlation_id":"9c267328-7772-41de-bf77-745a23318adc"}
Comments
Post a Comment