Пример #1
0
        public bool RegisterWithServerManagement(string emailAddress, string recoveryPassphrasePlaintext,
            out string registrationIdentifier, out string clientToken)
        {
            registrationIdentifier = "";
            clientToken = "";

            var apiClient = GetDefaultApiClientForServerManagement();
            
            var recoveryHash = HashUtil.GenerateServerManagerRecoveryPasswordHash(
                emailAddress, recoveryPassphrasePlaintext);

            var request = new Register
            {
                EmailAddress = emailAddress,
                RecoveryPasswordClientHash = recoveryHash
            };

            Register.ResponseParams response;
            try
            {
                response = request.GetResponse(apiClient);
            }
            catch (RequestException e)
            {
                Logger.Warning("Failed to register with the management API: " + e.Message);
                return false;
            }

            registrationIdentifier = response.RegistrationIdentifier;
            clientToken = response.ClientToken;
            return true;
        }