ConnectyCube / connectycube-reactnative-samples

Chat and Video Chat code samples for React Native, ConnectyCube
https://connectycube.com
Apache License 2.0
125 stars 111 forks source link

SASLError: not-authorized #115

Closed chris-umt closed 4 years ago

chris-umt commented 4 years ago

Package.json

    "react": "16.13.1",
    "react-native": "0.63.2",
    "react-native-connectycube": "^3.6.1",

Init CC

 ConnectyCube.init(CREDENTIALS, CONFIG);
const session = await ConnectyCube.createSession();
const userSession = await ConnectyCube.createSession(userCredentials);
ConnectyCube.chat.connect(userCredentials).then(() => console.log("CONNECTED")).catch(e => console.log("ERROR",e))

Both sessions are valid, the error is thrown when I try to connect to chat

[Chat] Connect with parameters  {login: "LOGIN_USER", password: "LOGIN_PASS"}
cubeInternalUtils.js:115 [Chat] status connecting wss://chat.connectycube.com:5291
RCTLog.js:47 SocketRocket: In debug mode.  Allowing connection to any root cert
cubeInternalUtils.js:115 [Chat] status connect 
cubeInternalUtils.js:115 [Chat] CONNECTING
cubeInternalUtils.js:115 [Chat] status opening 
cubeInternalUtils.js:115 [Chat] SENT: <open version="1.0" xmlns="urn:ietf:params:xml:ns:xmpp-framing" to="chat.connectycube.com"/>
cubeInternalUtils.js:115 [Chat] RECV: <open xmlns='urn:ietf:params:xml:ns:xmpp-framing' from='chat.connectycube.com' id='204ba3c6-966d-48fa-864d-0602aeab9320' version='1.0' xml:lang='en' />
cubeInternalUtils.js:115 [Chat] status open <open xmlns="urn:ietf:params:xml:ns:xmpp-framing" from="chat.connectycube.com" id="204ba3c6-966d-48fa-864d-0602aeab9320" version="1.0" xml:lang="en"/>
cubeInternalUtils.js:115 [Chat] RECV: <stream:features xmlns:stream="http://etherx.jabber.org/streams"><sm xmlns="urn:xmpp:sm:3"/><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism><mechanism>PLAIN_FAST</mechanism></mechanisms><ver xmlns="urn:xmpp:features:rosterver"/><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression></stream:features>
cubeInternalUtils.js:115 [Chat] SENT: <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">AHVuZGVmaW5lZC0yODQzAFRNRlZzSXFHZ1ViblFKNFE5Q2xzcXpnNUJhZjE=</auth>
cubeInternalUtils.js:115 [Chat] RECV: <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>
cubeInternalUtils.js:115 [Chat] ERROR: SASLError: not-authorized
...
Possible Unhandled Promise Rejection (id: 2):
Error: Connection is not offline

Any help is appreciated Thanks

DaveLomber commented 4 years ago

it means your credentials are not valid or user id is not valid

To be clear,

userCredentials probably a wrong one I see you pass a login field, but instead you should pass userId

https://developers.connectycube.com/js/messaging?id=connect-to-chat

chris-umt commented 4 years ago

Replaced login with userId Thanks @DaveLomber