Skip to content

Uncaught TypeError: Cannot read property 'sigBytes' of undefined #15

@tmayr

Description

@tmayr

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 + "&timestamp=" + 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions