I have two sites, a site that users login to and manage their account and site that has no UI and is nothing more than a API to store and retrieve content. Both of these sites use the same Owin ASP.Net Identity 2.0 setup. The UI site uses cookies for obvious reasons and the API site uses Bearer tokens. I need to be able to call the API methods/urls from the UI site with the current users authentication. In short I need to generate a valid Bearer token in the UI site to add to the HTTP headers when making the Rest API calls.
I was looking for some way to use a "trusted" client authentication and call the /Token url for the API to generate the Bearer token, or since both sites share the same code and user table call a Owin method to generate the Bearer Token in the UI sites code that I can pass to the API headers and the API site sees it as a valid token.
If you need anymore info, just let me know.
Update: Please see updated answer below with correct way of doing this with oAuth Implicit flow.