예제 #1
0
        public bool access_token(SeekOauthKey key, string oauthip)
        {
            string           url  = "http://" + oauthip + "/oauth/access_token";
            List <Parameter> pars = new List <Parameter>();

            pars.Add(new Parameter("grant_type", "none"));
            pars.Add(new Parameter("client_id", key.CustomKey));
            pars.Add(new Parameter("client_secret", key.CustomSecret));
            SeekRequest request       = new SeekRequest();
            string      requeststring = request.SyncRequest(url, "POST", pars, null);
            JsonReader  reader        = new JsonTextReader(new StringReader(requeststring));

            //string msg = "";
            while (reader.Read())
            {
                if (reader.Path.Equals("access_token") && reader.TokenType.ToString().Equals("String"))
                {
                    SeekOauthKey.TokenKey = reader.Value.ToString();
                }
                else if (reader.Path.Equals("refresh_token") && reader.TokenType.ToString().Equals("String"))
                {
                    key.RefreshTokenKey = reader.Value.ToString();
                }
                //msg += "TokenType:" + reader.TokenType + "|ValueType:" + reader.ValueType.Name + "|Value:" + reader.Value + "|Path:" + reader.Path + "\n";
            }
            //// SeekOauthKey.TokenKey = msg;
            //SeekOauthKey.TokenKey = GetJsonValue(requeststring, "access_token");
            //key.RefreshTokenKey = GetJsonValue(requeststring, "refresh_token");
            if (SeekOauthKey.TokenKey == null)
            {
                return(false);
            }
            return(true);
        }
예제 #2
0
        public string get_nsrxx(SeekOauthKey key)
        {
            string           url  = "http://192.168.1.247/crmrest/crm.api/nsrxx/420104629007840/json";
            List <Parameter> pars = new List <Parameter>();

            pars.Add(new Parameter("oauth_token", SeekOauthKey.TokenKey));
            SeekRequest request       = new SeekRequest();
            string      requeststring = request.SyncRequest(url, "GET", pars, null);

            return(requeststring);
        }
예제 #3
0
        public bool grant_type(SeekOauthKey key)
        {
            string           url  = "http://192.168.1.202/oauth/access_token";
            List <Parameter> pars = new List <Parameter>();

            pars.Add(new Parameter("grant_type", "refresh_token"));
            pars.Add(new Parameter("client_id", key.CustomKey));
            pars.Add(new Parameter("client_secret", key.CustomSecret));
            pars.Add(new Parameter("refresh_token", key.RefreshTokenKey));
            SeekRequest request       = new SeekRequest();
            string      requeststring = request.SyncRequest(url, "POST", pars, null);

            SeekOauthKey.TokenKey = GetJsonValue(requeststring, "access_token");
            key.RefreshTokenKey   = GetJsonValue(requeststring, "refresh_token");
            if (SeekOauthKey.TokenKey == null)
            {
                return(false);
            }
            return(true);
        }