Getting Started Guide

Creating User Access Tokens

Now that we have created an Application and generated "App Token", let's create user access tokens. These user access tokens will be used in your client-side applications (Android, iOS, Flutter, Web, etc.) for authentication and enabling communication between users.

Every user on your app requires a user access token to use mesibo real-time APIs for messaging, calls, conferencing, etc. You can generate tokens using mesibo Backend APIs with just two parameters:

1. Address

A unique string ID for the user, e.g. phone number, email, enterprise ID, etc.

2. App ID

For Android, this is the package name in AndroidManifest.xml. For iOS, it is the Bundle ID in Xcode. For other platforms you can use any string and call setAppName. This serves as a security measure, restricting users from using the user access token on unintended platforms or apps.

There is no restriction on the number of different App IDs. The users from the sane apps having completely different App IDs can communicate with each other once you generate access tokens for them.

Generating User Access Tokens

Generally, user access tokens are dynamically generated on need basis, typically when your users signup. However, for this sample app, we'll manually generate tokens for two test users to facilitate messaging and calling between them.

Note that users and groups are app-specific - users across apps can't communicate. Additionally, there won't be any conflicts if the same user exists in another application.

To create a user access token, send the following JSON request to https://api.mesibo.com/backend/ with your app token generated earlier. Here we use com.mesibo.firstapp as the app ID to match the GitHub sample code, but you can change it to match your actual app.

{
  "op":"useradd",
  "token": "87pbh20pzehd9ld0o0pxqx9h80jjqfu9ipul4l00fnb55pbfx9mxyyk4uyr1iwuw",
  "user": {
	"address":"xyz@example.com",

  	"token": {
		"appid": "com.mesibo.firstapp",
		"expiry": 525600
  	}
  }
}

You can use the mesibo backend API explorer tool to send requests and view the responses.

Alternatively, you can also use curl, Postman, or any of your favorite tools to send API requests.

curl -X POST https://api.mesibo.com/backend 
   -H 'Content-Type: application/json'
   -d '{"op":"useradd", "token":"87pbh20pzehd9ld0o0pxqx9h80jjqfu9ipul4l00fnb55pbfx9mxyyk4uyr1iwuw", ...}'

If using curl, it's more convenient to download the mesibo-backend-payload.json, modify and send as:

curl -X POST https://api.mesibo.com/backend 
   -H 'Content-Type: application/json'
   -d @mesibo-backend-payload.json

The above API returns a JSON response like this,

Response

{
"user": {
	"uid":"5302",
	"token":"cn9cvk6gnm15e7lrjb2k7ggggax5h90n5x7dp4sam6kwitl2hmg4cmwabet4zgdw"
},
"op":"useradd",
"result":true
}

The token returned in the above API JSON response is the user access token, which will be used by real-time API to connect to mesibo real-time server (using setAccessToken API).

You can now create more test users in a similar fashion so that you can test messaging between them. You can also send messages to a particular user using the consoleopen_in_new in the ‘Users’ section.

Let's now build our first mesibo app to send and receive messages!