예제 #1
0
        /// <summary>
        /// Step2:通过Authorization Code获取Access Token、openid
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static WeChat_AccessToken_ResultEntity AccessToken(WeChat_AccessToken_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars = LoginBase.EntityToPars(entity);

            string result = LoginBase.HttpTo.Url(WeChatConfig.API_AccessToken + "?" + pars);

            var outmo = LoginBase.ResultOutput <WeChat_AccessToken_ResultEntity>(result);

            return(outmo);
        }
예제 #2
0
        /// <summary>
        /// 获取 access token
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static Google_AccessToken_ResultEntity AccessToken(Google_AccessToken_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars = LoginBase.EntityToPars(entity);

            var result = NetnrCore.HttpTo.Post(GoogleConfig.API_AccessToken, pars);

            var outmo = LoginBase.ResultOutput <Google_AccessToken_ResultEntity>(result);

            return(outmo);
        }
예제 #3
0
        /// <summary>
        /// 获取 用户信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static Google_User_ResultEntity User(Google_User_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars = LoginBase.EntityToPars(entity);

            var result = Core.HttpTo.Get(GoogleConfig.API_User + "?" + pars);

            var outmo = LoginBase.ResultOutput <Google_User_ResultEntity>(result);

            return(outmo);
        }
예제 #4
0
        /// <summary>
        /// Step2:获取授权过的Access Token
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static Taobao_AccessToken_ResultEntity AccessToken(Taobao_AccessToken_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars = LoginBase.EntityToPars(entity);

            string result = LoginBase.RequestTo.Url(TaobaoConfig.API_AccessToken, pars);

            var outmo = LoginBase.ResultOutput <Taobao_AccessToken_ResultEntity>(result);

            return(outmo);
        }
예제 #5
0
        /// <summary>
        /// 获取access_token
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static StackOverflow_AccessToken_ResultEntity AccessToken(StackOverflow_AccessToken_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars   = LoginBase.EntityToPars(entity);
            var    result = Core.HttpTo.Post(StackOverflowConfig.API_AccessToken, pars);

            result = "{\"" + result.Replace("=", "\":\"").Replace("&", "\",\"") + "\"}";

            var outmo = LoginBase.ResultOutput <StackOverflow_AccessToken_ResultEntity>(result);

            return(outmo);
        }
예제 #6
0
        /// <summary>
        /// 请求授权地址
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static string AuthorizeHref(Gitee_Authorize_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            return(string.Concat(new string[] {
                GiteeConfig.API_Authorize,
                "?client_id=",
                entity.client_id,
                "&response_type=",
                entity.response_type,
                "&state=",
                entity.state,
                "&redirect_uri=",
                entity.redirect_uri.ToEncode()
            }));
        }
예제 #7
0
        /// <summary>
        /// 请求授权地址
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static string AuthorizeHref(StackOverflow_Authorize_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            return(string.Concat(new string[] {
                StackOverflowConfig.API_Authorize,
                "?client_id=",
                entity.client_id,
                "&scope=",
                entity.scope,
                "&state=",
                entity.state,
                "&redirect_uri=",
                entity.redirect_uri.ToEncode()
            }));
        }
예제 #8
0
        /// <summary>
        /// Step1:获取Authorization Code
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static string AuthorizationHref(WeChat_Authorization_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            return(string.Concat(new string[] {
                WeChatConfig.API_Authorization,
                "?appid=",
                entity.appid,
                "&response_type=",
                entity.response_type,
                "&scope=",
                entity.scope,
                "&state=",
                entity.state,
                "&redirect_uri=",
                NetnrCore.ToEncode(entity.redirect_uri)
            }));
        }
예제 #9
0
        /// <summary>
        /// 请求授权地址,密码登录
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static string AuthorizeHref_Password(DingTalk_Authorize_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            return(string.Concat(new string[] {
                DingTalkConfig.API_Authorize_Password,
                "?appid=",
                entity.appid,
                "&response_type=",
                entity.response_type,
                "&scope=",
                entity.scope,
                "&state=",
                entity.state,
                "&redirect_uri=",
                entity.redirect_uri.ToEncode()
            }));
        }
예제 #10
0
        /// <summary>
        /// 获取 用户信息
        /// </summary>
        /// <param name="entity">签名参数</param>
        /// <returns></returns>
        public static StackOverflow_User_ResultEntity User(StackOverflow_User_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars   = LoginBase.EntityToPars(entity);
            string result = Core.HttpTo.Get(StackOverflowConfig.API_User + "?" + pars);

            StackOverflow_User_ResultEntity outmo = null;

            var jo = result.ToJObject();

            if (jo.ContainsKey("items"))
            {
                outmo = LoginBase.ResultOutput <StackOverflow_User_ResultEntity>(jo["items"][0].ToJson());
            }

            return(outmo);
        }
예제 #11
0
        /// <summary>
        /// Step1:请求用户授权Token
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static string AuthorizeHref(Taobao_Authorize_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            return(string.Concat(new string[] {
                TaobaoConfig.API_Authorize,
                "?response_type=",
                entity.response_type,
                "&client_id=",
                entity.client_id,
                "&redirect_uri=",
                LoginBase.EncodeUri(entity.redirect_uri),
                "&state=",
                entity.state,
                "&view=",
                entity.view
            }));
        }