Search code examples
javascriptquickblox

Simple QuickBlox createSession giving 422 (application_id required)


I have just started with the QuickBlox javascript SDK, but I am getting an error ServiceProxy.ajax error 422 Unprocessable Entity {"errors":{"base":["application_id or app_id (deprecated) required"]}} trying to create a session.

my test.html:

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>QuickBlox API client - Content</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="quickblox-javascript-sdk/quickblox.js"></script>
    <script src="config.js"></script>
    <script src="main.js"></script>
  </head>
  <body>
    <h2>Test</h2>
  </body>
</html>

my main.js:

QB.init(CONFIG.appID, CONFIG.authKey, CONFIG.authSecret, CONFIG.debug);

QB.createSession(TEST_USER, function(err, result) {
  // callback function
  console.log('callback')
  if (err) {
    console.log(err.detail);
  } else {
  }
});

my config.js:

var CONFIG = {
  appId: 19335,
  authKey: 'UtcSpG3mWkLzVmU',
  authSecret: 'zXx2uFdRXvr5eR-',
  debug: true
};

var TEST_USER = {
  login: 'test1',
  password: 'hello123'
}

error:

POST https://api.quickblox.com/session.json 422 (Unprocessable Entity)
jquery.min.js:4
k.cors.a.crossDomain.sendjquery.min.js:4 
n.extend.ajaxquickblox.js:2549
ServiceProxy.ajaxquickblox.js:49
AuthProxy.createSessionquickblox.js:2391
QuickBlox.createSessionVM590:2
(anonymous function)VM584:762 InjectedScript._evaluateOnVM584:695 InjectedScript._evaluateAndWrapVM584:609 InjectedScript.evaluate
quickblox.js:2491

ServiceProxy.ajax error 422 Unprocessable Entity {"errors":{"base":["application_id or app_id (deprecated) required"]}}

Solution

  • The solution is very silly, stumbled across it myself.

    You copied the code from Quickblox's site.
    The key for Application ID is named 'appId' in the config JSON, while referenced as 'appID' from QB.init