QuickBlox Documentation

QuickBlox provides powerful Chat API and SDK to add real-time messaging and video calls to your web and mobile apps. Learn how to integrate QuickBlox across multiple platforms.

Authentication

Use this page to learn how to authenticate your users with QuickBlox.

🚧

This is our documentation for beta version of QuickBlox Flutter SDK. Please contact our Customer Support Team to provide your feedback, suggestions, and requests to improve this page.

Every user needs to authenticate with QuickBlox before using any QuickBlox functionality. When someone connects with an application using QuickBlox, the application needs to obtain a session token which provides temporary secure access to QuickBlox APIs. A session token is an opaque string that identifies a user and an application.

Visit our Key Concepts page to get an overall understanding of the most important QuickBlox concepts.

Before you begin

  1. Register a QuickBlox account. This is a matter of a few minutes and you will be able to use this account to build your apps.
  2. Configure QuickBlox SDK for your app. Check out our Setup page for more details.

Session token rights

There are different types of session tokens to support different use cases.

Application session token

Description

Application session token

This kind of access token is needed to read the app data. Has only READ access to resources. The expiration time after the last REST API request is 2 hours.

User session token

The user token is the most commonly used type of token. This kind of access token is needed any time the app calls an API to read, modify or write a specific user's data on their behalf. Has READ/WRITE access to resources. The expiration time after the last REST API request is 2 hours.

Get session

You can check whether you have a session or not.

try {
  QBSession? session = await QB.auth.getSession();
} on PlatformException catch (e) {
  // Some error occurred, look at the exception message for more details
}

Log in user

If you have an application session, you can upgrade it to a user session by calling login() method.

String login = "johnsmith";
String password = "superPassword";

try {
  QBLoginResult result = await QB.auth.login('login', 'password');
  QBUser? qbUser = result.qbUser;
  QBSession? qbSession = result.qbSession;
} on PlatformException catch (e) {
  // Some error occurred, look at the exception message for more details
}

Log out user

If you have a user session, you can downgrade it to an application session by calling logout() method.

try {
  await QB.auth.logout();
} on PlatformException catch (e) {
  // Some error occurred, look at the exception message for more details
}

Session expiration

The expiration time for a session token is 2 hours. If you will perform a query with an expired token, you will receive an error: "Required session does not exist". In this case, you have to recreate the session token.

Set existing session

Typically, a session token is stored in SDK after successful login and used for every subsequent API call. However, you may want to obtain and store the session on your server for better security. In this case, you can set the existing session token into SDK using the setSession() method.

try {
  QBSession? session = QBSession();
  session!.applicationId = 76730;
  session!.userId = 567527986;
  session!.expirationDate = "2025-01-23T01:23:45.678+09:00";
  session!.token = "8b75a6c7191285499d890a81df4ee7fe49bc732a";
  QBSession? sessionResult = await QB.auth.setSession(session);
} on PlatformException catch (e) {
  // Some error occurred, look at the exception message for more details
}

Set the following fields of the qbSession.

Field

Required

Description

applicationId

yes

Application ID.

userId

yes

User ID.

expirationDate

yes

Session token expiration date.

token

yes

QuickBlox session token.

Updated 3 months ago


What's Next

Users

Authentication


Use this page to learn how to authenticate your users with QuickBlox.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.