title: Authentication Failed Error - XMPPFramework - not-authorized
body: <p>After successfully connecting to the server, ie. after a successful callback to </p>
  
  <p><code>- (void) xmppStreamDidConnect:(XMPPStream *)sender</code></p>
  
  <p>I sometimes get an authentication failure, ie. the following callback is called:</p>
  
  <ul>
  <li>(void) xmppStream:(XMPPStream *)sender didNotAuthenticate:(NSXMLElement *)error</li>
  </ul>
  
  <p>The <code>NSXMLElement</code> looks like this:</p>
  
  <p><code>&lt;failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"&gt;&lt;not-authorized/&gt;&lt;text&gt;The response provided by the client doesn't match the one we calculated.&lt;/text&gt;&lt;/failure&gt;</code></p>
  
  <p>Like I said, I get this once in a while. I've traced the issue and I've tried several things so far.
  Things that's I have looked into and I can confirm so far:</p>
  
  <ul>
  <li>The username and password are 100% correct</li>
  <li>I'm using the SCRAM-SHA-1 authentication mechanism (<code>XMPPSCRAMSHA1Authentication</code>)</li>
  <li>My server supports the PLAIN mechanism as well and it fails with that as well (<code>XMPPPlainAuthentication</code>)</li>
  <li>If I try to force a disconnect when I get this error (<code>[xmppStream disconnect]</code>) and then in the <code>xmppStreamDidDisconnect</code> callback I try to re-open the stream (<code>[xmppStream connectWithTimeout:XMPPStreamTimeoutNone error:&amp;error]</code>) then I get into an infinite loop because the authentication fails consistently</li>
  </ul>
  
  <p>Now, I looked into this even further and when using the SCRAM-SHA-1 mechanism it looks like it fails on the second challenge. The client sends something (seemingly valid) to the server but the server doesn't like it and throws the <code>not-authorized</code> error.</p>
  
  <p>Thoughts anyone?</p>