2

I'm trying to create from the mobile app an API Session with user authorization (in the same call) on QuickBlox using this ajax call.

var url = 'https://api.quickblox.com/session.json';
var data = 'application_id=' + QB.appId + '&auth_key=' + QB.authKey + '&timestamp=' + s.timestamp + '&nonce=' + s.nonce + '&signature=' + s.signature + '&user[login]=' + username + '&user[password]=' + password;
$.ajax({
    type: 'POST',
    url: url,
    data: data,
    success: successCallback,
    error: errorCallback
});

Note that username and password are replaced with text strings that correspond to a real user on QuickBlox's app.

Quickblox returns this error :

{
    "readyState":4,
    "responseText":" {
        "errors":{
            "base":["Unexpected signature"]
        }
    }",
    "status":422,
    "statusText":"Unprocessable Entity"
}

But if I create from the mobile app the same API Session WITHOUT user authorization on QuickBlox using this data string (the same without user and pass).

var data = 'application_id=' + QB.appId + '&auth_key=' + QB.authKey + '&timestamp=' + s.timestamp + '&nonce=' + s.nonce + '&signature=' + s.signature;

QuickBlox creates the session correctly. Can someone tell me where is the mistake?.

Thank you in advanced. ;-)

cesar
  • 36
  • 2
  • I can create an API Session and a user authorization doing two querys but I want to do it in just one query. Quickblox documentation says that it is possible, but I have not been able to do it. Any suggestion? – cesar Aug 04 '14 at 13:15
  • 1
    It seems that you incorrectly create signature with native JS. Use QuickBlox JS SDK. The following links maybe useful to you http://quickblox.com/developers/Javascript#A_couple_of_words_about_Authentication_and_Authorization and http://quickblox.com/developers/Authentication_and_Authorization#Signature_generation – Darya Aug 05 '14 at 10:11
  • Thank you Dayra for your suggestion. I tried to use QuickBlox JS SDK but I had problems with require() calls in quickblox.js and I don't know how to solve it. Additionally, I haven't found domumentation about methods defined for each module QB.users, QB.data (Custom Objects), QB.content, QB.location, QB.location.geodata, QB.location.places, QB.messages, QB.messages.tokens, QB.messages.subscriptions and QB.messages.events. I think that QuickBlox has a great potential, but its tricky for newbies. Would appreciate any help. – cesar Aug 06 '14 at 09:26
  • 1
    Hi Cesar. Which browser are you experiencing issues with regarding the `require()` calls? Did you use `quickblox.min.js`? The JS SDK follows a fairly standard pattern for API calls - every method accepts either an object, string or integer and a callback with "error" or "response" parameters e.g. `QB.createSession({login: , password: }, function(error, response) {...});`. You have a point about the documentation lacking. Your questions and feedback would be super helpful - please send me an email at alex.bass@quickblox.com and I'll help you as much as I can! – Alex Bass Aug 06 '14 at 15:20
  • Hi Alex. I'm currently developing a mobile web app with Phonegap, jQuery Mobile and QuickBlox as BaaS. I'm testing the app with Chrome 36.0.1985.125 from a iMAC running OSX 10.9.4 (Mavericks). For testing purposes, I'm using quickblox.js instead of quickblox.min.js, I guess it does not matter. If you prefer, I can send you an email with detailed information about this question and of course my feedback about Quickblox. Once solved this question, I'll update here this question in order to share the solution. – cesar Aug 06 '14 at 23:17
  • @Darya I can't use SDK, I'm using in PHP, so I'm using the REST API, and getting this error too. See my question about it: http://stackoverflow.com/questions/31733629/quickblox-rest-api-unexpected-signature-on-laravel – Maykonn Jul 31 '15 at 15:05

0 Answers0