public OidcClientOptions(Endpoints endpoints, string clientId, string clientSecret, string scope, string redirectUri, IWebView webView)
            : this(clientId, clientSecret, scope, redirectUri, webView)
        {
            if (endpoints == null) throw new ArgumentNullException(nameof(endpoints));
            endpoints.Validate();

            _endpoints = new Lazy<Task<Endpoints>>(() => Task.FromResult(endpoints));
        }
Esempio n. 2
0
        public static async Task<Endpoints> LoadFromMetadataAsync(string authority)
        {
            var client = new HttpClient();
            var url = authority.EnsureTrailingSlash() + ".well-known/openid-configuration";

            var json = await client.GetStringAsync(url);

            var doc = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);

            var endpoints = new Endpoints
            {
                Authorize = doc["authorization_endpoint"].ToString(),
                Token = doc["token_endpoint"].ToString(),
                EndSession = doc["end_session_endpoint"].ToString(),
                UserInfo = doc["userinfo_endpoint"].ToString(),
            };

            // todo: replace with local validation
            endpoints.IdentityTokenValidation = authority.EnsureTrailingSlash() + "connect/identitytokenvalidation";

            return endpoints;
        }