Esempio n. 1
0
        public static Account Login(Urls urls, string accessToken)
        {
            var client  = new RestClient(urls.UserUrl);
            var request = new RestRequest("Login");

            request.AddParameter("Authorization", accessToken, ParameterType.HttpHeader);
            var response   = client.Post(request);
            var content    = StringEncrypt.Decrypt(response.Content, userKey);
            var definition = new { Code = "", Msg = "", Account = new SlitherEvo.Account() };

            return(JsonConvert.DeserializeAnonymousType(content, definition).Account);
        }
Esempio n. 2
0
        public static Account CreateAccount(Urls urls, string accessToken)
        {
            var client  = new RestClient(urls.UserUrl);
            var request = new RestRequest("Login");

            request.AddParameter("Authorization", accessToken, ParameterType.HttpHeader);
            var input = StringEncrypt.Encrypt(JsonConvert.SerializeObject(new { Language = "Taiwan" }), userKey);

            request.AddParameter("application/json", input, ParameterType.RequestBody);
            var response   = client.Post(request);
            var content    = StringEncrypt.Decrypt(response.Content, userKey);
            var definition = new { Code = "", Msg = "", Account = new SlitherEvo.Account() };

            return(JsonConvert.DeserializeAnonymousType(content, definition).Account);
        }
Esempio n. 3
0
        private static string Authentication(Urls url, string devicedId)
        {
            var client  = new RestClient(url.UserUrl);
            var request = new RestRequest("Authentication");
            var input   = JsonConvert.SerializeObject(new { DeviceID = devicedId, SecretOpenID = "" });

            input = StringEncrypt.Encrypt(input, userKey);
            request.AddParameter("application/json", input, ParameterType.RequestBody);

            var response = client.Post(request);
            var content  = StringEncrypt.Decrypt(response.Content, userKey);

            var definition = new { Code = "", Msg = "", AccessToken = "" };
            var result     = JsonConvert.DeserializeAnonymousType(content, definition);

            return(result.AccessToken);
        }