Share via


What is the proper way to use .AsJwt()?

Question

Friday, March 30, 2018 3:40 PM

This is a bit of a repost of a issue I submitted to the documentation site. I wanted to post it here to give it more visibility and perhaps get someone other than the document creator to provide an answer.

In the documentation example User identity throttling it has the following code example.

<rate-limit-by-key calls="10"
    renewal-period="60"
    counter-key="@(context.Request.Headers.GetValueOrDefault("Authorization","").AsJwt()?.Subject)" />

This will not work as the value of Authorization will be something like Bearer eyJ0eXAiO... this causes .AsJwt() to return null. To get this to work I had to do 

 context.Request.Headers.GetValueOrDefault("Authorization","").Substring("Bearer ".Length).AsJwt()

to get .AsJwt() to not return null.

Is this a error in the documentation or is this a error in the .AsJwt() call?

All replies (1)

Wednesday, April 4, 2018 3:21 AM

There is nothing wrong with the document. We are working on this and stay tuned for the further update : https://blogs.msdn.microsoft.com/apimanagement/.

Do click on "Mark as Answer" on the post that helps you, this can be beneficial to other community members.