コード例 #1
0
        public async Task <TokenCookies> GetMcfCookiesByBpAsync(long bpNumber)
        {
            TokenCookies cookies = null;

            RedisKey key         = $"authentication:mcf:nojwt:{bpNumber}";
            var      cookiesJson = _redis.StringGet(key);

            if (cookiesJson.IsNullOrEmpty)
            {
                var client  = GetRestClient(_loadBalancerUrl, true);
                var request = new RestRequest($"/v1.0/authentication/mcf-token/{bpNumber}", Method.GET);

                var result = await client.ExecuteTaskAsync(request);

                cookiesJson = result.Content;
            }

            cookies = JsonConvert.DeserializeObject <TokenCookies>(cookiesJson);

            return(cookies);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="jwtToken"></param>
        /// <returns></returns>
        // ReSharper disable once InconsistentNaming
        public TokenCookies GetMcfCookies(string jwtToken, string channel)
        {
            TokenCookies cookies = null;

            RedisKey key         = $"authentication:{jwtToken}";
            var      cookiesJson = _redis.StringGet(key);

            if (cookiesJson.IsNullOrEmpty)
            {
                var client  = GetRestClient(_loadBalancerUrl, true);
                var request = new RestRequest("/v1.0/authentication/mcf-token", Method.GET);
                request.AddHeader("Authorization", jwtToken);
                request.AddHeader("request-channel", channel);
                var result = client.Execute(request);

                cookiesJson = result.Content;
            }

            cookies = JsonConvert.DeserializeObject <TokenCookies>(cookiesJson);

            return(cookies);
        }