一、作为认证服务器,首先需要提供一个可以通过appid/appsecret来获取token这样的一个接口,于是便有了以下代码。

自己开发实现OAuth做webapi认证
    public class AuthController : ApiController
    {
        [HttpGet]
        public HttpResponseMessage Token(string appid = "", string appsecret = "")
        {
            ApiResponseEntity rep;
            var isv = AppManage.Instance.GetAppISV(appid, appsecret);
            if (isv != null)
            {
                string token = TokenManage.Instance.CreateToken(appid);

                rep = new ApiResponseEntity
                {
                    Status = InterfaceStatus.Success,
                    BizData = new
                    {
                        AccessToken = token
                    }
                };
            }
            else
            {
                rep = new ApiResponseEntity()
                {
                    Status = InterfaceStatus.Parm_Missing,
                    Message = "param error"
                };
            }
            return rep.ToHttpResponseMessage();
        }
}
自己开发实现OAuth做webapi认证

相关文章:

  • 2021-06-02
  • 2022-12-23
  • 2022-02-02
  • 2021-11-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
  • 2021-08-28
  • 2022-12-23
相关资源
相似解决方案