Ejemplo n.º 1
0
        public async Task <ServiceClientCredentials> GetServiceCredentials([NotNull] ClientCredentials credentials, IEnumerable <string> scopes = null)
        {
            var scopesArray = scopes == null ? new string[0] : scopes.ToArray();
            var key         = $"{credentials.Id}_{credentials.IdentityProvider}_scopes:{string.Join(",", scopesArray)}";

            if (_cache.ContainsKey(key))
            {
                return(_cache[key]);
            }


            var serviceClientCredentials = await ApplicationTokenProvider.LogonWithEryphClient(credentials, scopesArray).ConfigureAwait(false);

            return(_cache.GetOrAdd(key, serviceClientCredentials));
        }