Authentication and Users
Every user has to authenticate with ConnectyCube before using any ConnectyCube functionality.
When someone connects with an application using ConnectyCube, the application will need to obtain a session token which provides temporary, secure access to ConnectyCube APIs.
A session token is an opaque string that identifies a user and an application.
Session token rights
There are different types of session tokens to support different use cases:
Session Token Type | Description |
---|---|
Application session token | This kind of access token is needed to read the app data. Has only READ access to resources |
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 |
Create session token
To create an application session use the following code:
Response example from ConnectyCube.createSession()
:
To create a user session use the following code:
Response example from ConnectyCube.createSession(userCredentials)
:
Create guest session
To create a session with guest user use the following code:
Response example from ConnectyCube.createSession(guestUserCredentials)
:
Upgrade session token (user login)
If you have an application session, you can upgrade it to a user session by calling login
method:
Response example from ConnectyCube.login(userCredentials)
:
Authentication via phone number
Sign In with phone number is supported with (Firebase integration).
You need to create Firebase project_id
and obtain Firebase access_token
after SMS code verification, then pass these parameters to login
method:
!> Important note: in order to login via phone number you need to create a session token first.
Authentication via Firebase email
Sign In with email is supported with (Firebase integration).
You need to create Firebase project_id
and obtain Firebase access_token
after email/password verification, then pass these parameters to login
method:
!> Important note: in order to login via email you need to create a session token first.
Authentication via external identity provider
Custom Identity Provider (CIdP) feature is necessary if you need to use an external database to authenticate ConnectyCube application users. It allows you to integrate your existing users base with ConnectyCube easily and works the same way as Facebook/Twitter SSO.
With Custom Identity Provider feature you can continue using your user database instead of storing/copying user data to ConnectyCube database.
More info available on a dedicated Custom Identity Provider guide page.
After the Custom Identity Provider configuration, you can use same ConnectyCube user login API to authenticate ConnectyCube users against an external identity provider base.
Downgrade session token (user logout)
If you have a user session, you can downgrade it to an application session by calling logout
method:
Session expiration
Expiration time for session token is 2 hours after last request to API. If you perform query with expired token, you will receive the error Required session does not exist. In this case you need to recreate a session token.
There is a special callback function to handle this case:
Destroy session token
To destroy a session use the following code:
User signup
Response example from ConnectyCube.users.signup(userProfile)
:
Only login (or email) + password are required.
User profile update
Response example from ConnectyCube.users.update(updatedUserProfile)
:
If you want to change your password, you need to provide 2 parameters: password
and old_password
. Updated user
entity will be returned.
User avatar
You can set a user’s avatar. You just need to upload it to the ConnectyCube cloud storage and then connect to user.
Response example from ConnectyCube.storage.createAndUpload(fileParams)
:
Now, other users can get you avatar:
Password reset
It’s possible to reset a password via email:
If provided email is valid - an email with password reset instruction will be sent to it.
Retrieve users V2
Examples
Retrieve users by ID
Retrieve users by login
Retrieve users by last_request_at
More information (fields, operators, request rules) available here
Retrieve users V1 (Deprecated)
Retrieve users by ID (Deprecated)
Response example from ConnectyCube.users.get(params)
- see
Retrieve user by login (Deprecated)
Retrieve user by email (Deprecated)
Retrieve users by full name (Deprecated)
Retrieve user by phone number (Deprecated)
Retrieve user by external ID (Deprecated)
Retrieve users by tags
Delete user
A user can delete himself from the platform: