Esempio n. 1
0
        public static clsTokenResponse GetGspToken(GSPCredentials credential)
        {
            clsTokenResponse token = null;

            try
            {
                var url    = credential.base_url + "/gsp/authenticate?grant_type=token";
                var client = new WebApiClientToken("", "");
                if (myUtils.IsInList(credential.Env, "test"))
                {
                    client.BuildHeaders = _client =>
                    {
                        _client.DefaultRequestHeaders.Add("gspappid", "6BF555F9196F44EA9F4F74AD67EE9F17");
                        _client.DefaultRequestHeaders.Add("gspappsecret", "2517BCE5G0D1FG47E0GA744GA1F15599D947");
                    };
                }
                else
                {
                    client.BuildHeaders = _client =>
                    {
                        _client.DefaultRequestHeaders.Add("gspappid", "260034364AC149F98DF902C3A85566BA");
                        _client.DefaultRequestHeaders.Add("gspappsecret", "58B3D4EAGA57EG4784GBC26GE230536DFF9C");
                    };
                }
                client.PrepareQueryString(url, new Dictionary <string, string>());
                var values         = new List <KeyValuePair <string, string> >();
                var requestContent = new FormUrlEncodedContent(values);
                token = client.Post <clsTokenResponse>(requestContent);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
            return(token);
        }
Esempio n. 2
0
        public static GSPCredentials GenerateCredential(string code, string API, string env)
        {
            GSPCredentials selected = null;
            string         filename = System.IO.Path.Combine(GSTNConstants.base_path, "gsp.json");

            if (System.IO.File.Exists(filename))
            {
                string str1 = System.IO.File.ReadAllText(filename);
                var    lst  = JsonConvert.DeserializeObject <List <GSPCredentials> >(str1);
                selected = lst.Where(item => (myUtils.IsInList(item.code, code) && myUtils.IsInList(API, item.API) && myUtils.IsInList(env, item.Env))).FirstOrDefault();
            }
            return(selected);
        }