I am hoping someone can advise me on this please.
I have been following a modified form of this tutorial Getting started with thinktecture Identity server to try to setup a site with OpenId Connect authentication.
I have this set up:
An Asp.NET MVC project acting as the Identity Server
An Asp.NET MVC project acting as the secured website
This above setup is working perfectly. When someone attempts to access a controller with the [Authorise] attribute in the secured website, they are redirected to the Identity server to login, and then redirected back to the secured website after successful login.
I would now like to add a web api into the mix. I have created a WebApi project, but unlike in the tutorial where it is called server side using a 'service account', I would like to call it client side (JQuery) from the secured website with the identity of the currently logged in user.
I understand that I need to use a bearer token in the authentication header.
My question is: How do I get the bearer token for the currently logged in user on the client side so I can set the header? (The user is already logged in.)
Many thanks in advance for your help