Beispiel #1
0
        /// <summary>
        /// 测试接口
        /// </summary>
        /// <param name="accessTokenUrl"></param>
        /// <param name="code"></param>
        /// <param name="apiKey"></param>
        /// <param name="secret"></param>
        /// <param name="redirect_uri"></param>
        /// <returns></returns>
        public string GetResult(string accessTokenUrl, string code, string apiKey, string secret, string redirect_uri)
        {
            Dictionary<string, string> queryParams = new Dictionary<string, string>();
            queryParams.Add("grant_type", "authorization_code");
            queryParams.Add("code", code);
            queryParams.Add("client_id", apiKey);
            queryParams.Add("client_secret", secret);
            queryParams.Add("redirect_uri", redirect_uri);

            HTTPBase httpBase = new HTTPBase();
            string result = httpBase.Post(accessTokenUrl, queryParams);
            return result;
        }
Beispiel #2
0
 /// <summary>
 /// 或得用户信息
 /// </summary>
 /// <param name="userinfoUrl">请求地址</param>
 /// <param name="accessToken">access_token</param>
 /// <param name="fileds">字段</param>
 /// <returns></returns>
 public string GetUserInfo(string userinfoUrl, string accessToken, string fileds)
 {
     string retUrl = userinfoUrl + "?";
     retUrl += "access_token=" + HttpUtility.UrlEncode(accessToken) + "&";
     retUrl += "fileds=" + HttpUtility.UrlEncode(fileds);
     Dictionary<string, string> queryParams = new Dictionary<string, string>();
     HTTPBase httpBase = new HTTPBase();
     string result = httpBase.Get(retUrl, queryParams);
     return result;
 }
Beispiel #3
0
        /// <summary>
        /// 用户名密码方式获取AccessToken
        /// </summary>
        /// <param name="accessTokenUrl">accessToken的url</param>
        /// <param name="userName">用户名</param>
        /// <param name="passWord">密码</param>
        /// <param name="apiKey">APIKEY</param>
        /// <param name="secret">SECRECT</param>
        /// <param name="scope">scope</param>
        /// <returns>返回的数据</returns>
        public KxReturn UserNamePassWordCredentials(string accessTokenUrl, string userName, string passWord, string apiKey, string secret, string scope)
        {
            Dictionary<string, string> queryParams = new Dictionary<string, string>();
            queryParams.Add("grant_type", "password");
            queryParams.Add("username", userName);
            queryParams.Add("password", passWord);
            queryParams.Add("client_id", apiKey);
            queryParams.Add("client_secret", secret);
            queryParams.Add("scope", scope);

            HTTPBase httpBase = new HTTPBase();
            string result = httpBase.Post(accessTokenUrl, queryParams);

            return new AccessToken(result);
        }
Beispiel #4
0
        /// <summary>
        /// 更新token的方式请求access_token
        /// </summary>
        /// <param name="accessTokenUrl">accessToken的URL</param>
        /// <param name="apiKey">APIKEY</param>
        /// <param name="secret">Secret</param>
        /// <param name="scope">权限Scope</param>
        /// <param name="refresh_token">refreshToken,更新凭证</param>
        /// <returns>返回的数据</returns>
        public KxReturn RefreshTokenCredentials(string accessTokenUrl, string apiKey, string secret, string scope, string refresh_token)
        {
            Dictionary<string, string> queryParams = new Dictionary<string, string>();
            queryParams.Add("grant_type", "refresh_token");
            queryParams.Add("client_id", apiKey);
            queryParams.Add("client_secret", secret);
            queryParams.Add("scope", scope);
            queryParams.Add("refresh_token", refresh_token);

            HTTPBase httpBase = new HTTPBase();
            string result = httpBase.Post(accessTokenUrl, queryParams);

            return new AccessToken(result);
        }