Пример #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;
        }
Пример #2
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);
        }
Пример #3
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);
        }