// if accountId is not null, this client registration is allocated in the login servers for the account (and restricted to users of that account) instead of the root login servers.
        public static OAuth2Client NewClient(string loginServerId, string accountId)
        {
            OAuth2Client resultClient = new OAuth2Client();

            resultClient._secretIsHashed = false;
            //
            ParsingHelper.ServerDetails?loginServerDetails = ParsingHelper.ExtractServerDetailsFromAccountServerId(loginServerId);
            if (loginServerDetails == null)
            {
                throw new Exception();
            }
            resultClient._loginServerDetails = loginServerDetails.Value;
            resultClient._id = null;
            //
            resultClient._accountId         = accountId;
            resultClient._accountId_IsDirty = true;
            //
            resultClient._tokenEndpointAuthMethod         = OAuth2TokenEndpointAuthMethod.None;
            resultClient._tokenEndpointAuthMethod_IsDirty = true;
            //
            resultClient._redirectUris  = new ListWithDirtyFlag <string>();
            resultClient._grantTypes    = new ListWithDirtyFlag <OAuth2GrantType>();
            resultClient._responseTypes = new ListWithDirtyFlag <OAuth2ResponseType>();
            resultClient._scopes        = new ListWithDirtyFlag <string>();
            //
            resultClient._registrationTokenIsHashed = false;
            //
            return(resultClient);
        }
        public static OAuth2InitialAccessToken NewToken(string loginServerId)
        {
            ParsingHelper.ServerDetails?loginServerDetails = ParsingHelper.ExtractServerDetailsFromAccountServerId(loginServerId);
            if (loginServerDetails == null)
            {
                throw new Exception();
            }

            OAuth2InitialAccessToken result = new OAuth2InitialAccessToken()
            {
                _loginServerDetails = loginServerDetails.Value,
                _id         = null,
                _softwareId = null,
                _accountId  = null,
                _timeUpdatedInUnixMicroseconds = null,
                _isCached = false,
            };

            return(result);
        }