Get IPrincipal from OAuth Bearer Token in OWIN

前端 未结 4 1505
说谎
说谎 2020-11-29 22:04

I have successfully added OAuth to my WebAPI 2 project using OWIN. I receive tokens and can use them in the HTTP Header to access resources.

Now I want to use those

4条回答
  •  孤城傲影
    2020-11-29 22:17

    in addition to johnny-qian answer, using this method is better to create DataProtector. johnny-qian answer, depends on IIS and fails on self-hosted scenarios.

    using Microsoft.Owin.Security.DataProtection;
    var dataProtector = app.CreateDataProtector(new string[]   {
         typeof(OAuthAuthorizationServerMiddleware).Namespace,
         "Access_Token",
         "v1"
    });
    

提交回复
热议问题