-
Notifications
You must be signed in to change notification settings - Fork 217
Closed
Description
I'm trying to generate a session after initialising QB with a token genreated from the server.
The token seems valid, when I use it on curl requests I get back the correct info, but when doing QB.createSession I'm getting an error, the following is the frontend code
QB.init(token, {debug:true});
QB.createSession(function(err, result){
console.log(err, result)
});
//Uncaught TypeError: Cannot read property 'sigBytes' of undefined
As far as I understand, the code above should work perfectly, when I try doing the init with the secrets/keys it works flawlessly.
Server code (python) to generate the token:
class QuickBlox(object):
"""
base class to be used with all QB classes
"""
# settings
qb_settings = settings.QUICKBLOX
application_id = qb_settings["ID"]
auth_key = qb_settings["KEY"]
auth_secret = qb_settings["SECRET"]
version = qb_settings["VERSION"]
# API URLs
api_root = "https://api.quickblox.com/"
users_url = api_root + "users.json"
login_url = api_root + "login.json"
session_url = api_root + "session.json"
content_type = "application/json"
class QBApplication(QuickBlox):
"""
class for interacting with the QuickBlox Application API
"""
def __init__(self):
self.app_token = self.get_application_token()
def get_application_token(self):
"""
this will return session data from QuickBlox.
"""
nonce = str(random.randint(1, 10000))
timestamp = str(int(time.time()))
signature_raw_body = ("application_id=" + self.application_id + "&auth_key=" + self.auth_key +
"&nonce=" + nonce + "×tamp=" + timestamp)
signature = hmac.new(self.auth_secret.encode(), signature_raw_body.encode(), sha1).hexdigest()
params = {
'application_id': self.application_id,
'auth_key': self.auth_key,
'timestamp': timestamp,
'nonce' : nonce,
'signature' : signature
}
response = requests.post(self.session_url, params=params)
session_data = response.json()
return session_data["session"]["token"]
Any insight on why this might be happening? I would really appreciate it!
Metadata
Metadata
Assignees
Labels
No labels