How to do caching of Authorization access token in web api C#?

I have two project. Project 1 is Php based web API which include OAuth and custom Authorization logic.Where Project 2 is C# REST API where each API should be authorized.To achieve this I am exposing Api from project 1 for Authorization, which is working perfect. By above flow for each request to Project 2 API's I have to authorize by hitting the Authorization API's of Project 1. Do we have any concept in C# or by using some caching technique so that I can check that each request is already validated or not .If not then I should call Authorization API.? Input for Authorization API is " Bearer token " which will be sent by client application.

Constraint :- I have to maintain two different projects and I have to reuse my auth provider API in another web api project. Thanks in advance.


you can use redis or any popular out proc cache mgmt to store your token & can be used by both of project.

https://redis.io/clients


You can use separate auth server, for example:

https://identityserver.github.io/Documentation/

And implement SSO(single-sign-on) functionality, if you needed.

Or you can implement your own authorization server, but strongly recommend you to use existing solutions.

Look into this article: http://bitoftech.net/2014/09/24/decouple-owin-authorization-server-resource-server-oauth-2-0-web-api/

链接地址: http://www.djcxy.com/p/35882.html

上一篇: 如何按价格获得物品?

下一篇: 如何在web api C#中授权访问令牌缓存?