/// <summary>
        /// Adds a phone resource.
        /// </summary>
        /// <param name="configure">The <see cref="Action{IdentityResourceBuilder}"/> to configure the phone scope.</param>
        public void AddPhone(Action <IdentityResourceBuilder> configure)
        {
            var resource = IdentityResourceBuilder.Phone();

            configure(resource);
            Add(resource.Build());
        }
        public void Configure(ApiAuthorizationOptions options)
        {
            var data = _configuration.Get <IdentityResourceDefinition>();

            if (data != null && data.Scopes != null)
            {
                var scopes = ParseScopes(data.Scopes);
                if (scopes != null && scopes.Length > 0)
                {
                    ClearDefaultIdentityResources(options);
                }
                foreach (var scope in scopes)
                {
                    switch (scope)
                    {
                    case IdentityServer4.IdentityServerConstants.StandardScopes.OpenId:
                        options.IdentityResources.Add(IdentityResourceBuilder.OpenId()
                                                      .AllowAllClients()
                                                      .FromConfiguration()
                                                      .Build());
                        break;

                    case IdentityServer4.IdentityServerConstants.StandardScopes.Profile:
                        options.IdentityResources.Add(IdentityResourceBuilder.Profile()
                                                      .AllowAllClients()
                                                      .FromConfiguration()
                                                      .Build());
                        break;

                    case IdentityServer4.IdentityServerConstants.StandardScopes.Address:
                        options.IdentityResources.Add(IdentityResourceBuilder.Address()
                                                      .AllowAllClients()
                                                      .FromConfiguration()
                                                      .Build());
                        break;

                    case IdentityServer4.IdentityServerConstants.StandardScopes.Email:
                        options.IdentityResources.Add(IdentityResourceBuilder.Email()
                                                      .AllowAllClients()
                                                      .FromConfiguration()
                                                      .Build());
                        break;

                    case IdentityServer4.IdentityServerConstants.StandardScopes.Phone:
                        options.IdentityResources.Add(IdentityResourceBuilder.Phone()
                                                      .AllowAllClients()
                                                      .FromConfiguration()
                                                      .Build());
                        break;

                    default:
                        throw new InvalidOperationException($"Invalid identity resource name '{scope}'");
                    }
                }
            }
        }
 /// <summary>
 /// Adds a phone resource.
 /// </summary>
 public void AddPhone() =>
 Add(IdentityResourceBuilder.Phone().Build());