Ejemplo n.º 1
0
        public override OpenApiResult <AccessGrant> UserAuthorize(SimpleTokenData tokenData)
        {
            if (!HttpContext.Current.IsAvailable())
            {
                throw new OAuthException("该方法仅能用于 HTTP 上下文的环境下。");
            }

            return(base.UserAuthorize(tokenData));
        }
        /// <summary>
        /// 获取授权
        /// </summary>
        public virtual OpenApiResult <AccessGrant> UserAuthorize(SimpleTokenData tokenData)
        {
            var result = OAuthOperator.GetToken(tokenData);

            if (result.Code == 0)
            {
                OnUserAuthorizeSuccess(result.Data);
            }
            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取服务端的Token
        /// </summary>
        /// <param name="tokenData">Token数据</param>
        /// <returns>授权对象</returns>
        public static OpenApiResult <AccessGrant> GetToken(SimpleTokenData tokenData)
        {
            UpdateClient();
            var url = UriPathBuilder.Combine(OAuthService.OAuthServicePath, "token");

            var data = new NameValueCollection();

            tokenData.UpdateDatas(data);
            var innerResult = client.HttpPostForResult <AccessGrant.InnerAccessGrant>(url, data);

            var result = new OpenApiResult <AccessGrant>()
            {
                Code = innerResult.Code, Message = innerResult.Message
            };

            if (innerResult.Data != null)
            {
                result.Data = innerResult.Data.Convert();
            }
            return(result);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 用户授权
 /// </summary>
 /// <returns></returns>
 public static OpenApiResult <AccessGrant> UserAuthorize(SimpleTokenData tokenData)
 {
     EnsureInit();
     return(OAuthProvider.UserAuthorize(tokenData));
 }