Beispiel #1
0
        public void TestDeserialize()
        {
            var    text  = new { Token = "tkn" };
            string json  = JsonMaker.Serialize(text);
            string token = JsonMaker.DeserializeToken(json);

            Assert.IsNotNull(token, "token != null");
            Assert.IsTrue(token == "tkn");
        }
Beispiel #2
0
        /// <summary>Get and store token</summary>
        /// <returns>Success of authorization</returns>
        public bool Authorize(string username, string password, out HttpStatusCode statusCode)
        {
            var    loginData = new { username = username, password = password };
            string json      = JsonMaker.Serialize(loginData);
            string tokenJson = Send(AuthorizationUri, json, "application/json", out statusCode);

            if (statusCode == HttpStatusCode.OK)
            {
                Token = JsonMaker.DeserializeToken(tokenJson);
            }
            return(Token != null);
        }