protected override string GetDefaultSignature( string api_uri, string method ) { Header hToken = new Header() { Name = XAuthToken.ToLower(), Value = this[XAuthToken] }; Header hTimestamp = new Header() { Name = XAuthTimestamp.ToLower(), Value = Functions.GetTimestampString() }; this[XAuthTimestamp] = hTimestamp.Value; return CreateSignatureSubject( method, api_uri, hTimestamp, hToken ); }
/// <summary> /// Used to login in Quatrix account /// </summary> /// <exception cref="QException"></exception> // <returns>True if user is successfully logged in. Otherwise - false.</returns> public bool Login( ) { this.Enable( false ); if (IsLoggedIn) { return true; } ValidateFields(); //Prepare data //SetRequestData( new Uri( Host ) ); this.encPass = EncPass( Password ); //URI for authorization string URI = "/session/login"; Header hTimestamp = new Header { Name = QRequest.XAuthTimestamp.ToLower(), Value = Functions.GetTimestampString() }; Header hLogin = new Header { Name = QRequest.XAuthLogin.ToLower(), Value = Email }; string signature = CreateSignatureSubject( System.Net.WebRequestMethods.Http.Get, URI, hLogin, hTimestamp ); try { IQuatrixRequest req = this; string res = req.CreateRequest( URI, null, signature ); //Account ac = ((IQuatrixRequest)this).CreateRequest<Account> ( URI, null, signature ); IsLoggedIn = !string.IsNullOrEmpty ( res );//ac.account_id ); if (IsLoggedIn) { LoginedEvent ( this, new EventArgs () ); } else { RemoveToken(); if (LoginFailedEvent != null) { LoginFailedEvent( this, new ErrorEventArgs( new QException( Error.api_not_logined ) ) ); } } } catch (QException) { RemoveToken (); if (LoginFailedEvent != null) { LoginFailedEvent( this, new ErrorEventArgs( new QException( Error.api_not_logined ) ) ); } else { throw new QException ( Error.api_not_logined ); } } return IsLoggedIn; }