ADH
ADH

Reputation: 3071

REST API Authentication using BootstrapContext and JWT Handler

I am using WIF 4.5 to authenticate my user and need to use the Security Token from the WIF 4.5 authentication to call a REST API.

Here is the code I am using to get the IMS Security Token for the currently logged in user.

BootstrapContext bootstrapContext = ClaimsPrincipal.Current.Identities.First().BootstrapContext as BootstrapContext;
var myToken = bootstrapContext.SecurityToken;

So, far, so good. The token exists and has the Id, ValidFrom, and ValidTo values. The Security Keys count is zero, but I am not sure if that is relevant.

Now, I need to know how to use this token to then call the REST API.

It seems like I am supposed to use the JWT Handler for this: https://blogs.msdn.microsoft.com/vbertocci/2012/11/20/introducing-the-developer-preview-of-the-json-web-token-handler-for-the-microsoft-net-framework-4-5/

But, I am having problems getting this to work. The code on the linked to page above actually does not compile as is. Some of the properties have been changed/renamed.

Upvotes: 0

Views: 205

Answers (0)

Related Questions