One-time key authorization
One-time key authorization
Authenticate users with one-time keys in the Voximplant mobile SDK.
There are some cases when you need to log in users into a web phone automatically, but do not want a plain text password (which is accepted by the login method) to be available in JavaScript code. This is where we can use the loginWithOneTimeKey method to log in.
Let us assume that you need to log a user myuser into an application myapp in your Voximplant account myaccount, and this user has the password mypass.
- Add a handler for the AuthResult event.
- Request a one-time authentication login key using the requestOneTimeLoginKey function.
Login key TTL
After you request your login key with requestOneTimeLoginKey, it expires after 5 minutes. If you require a one-time login key for this account from another device, the current login key expires.
- Calculate the token on your backend.
Please note
- myuser does not include @appname.accname.voximplant.com;
-
- this formula allows you to store only hashes on the backend, not passwords.
- Send this token using the loginWithOneTimeKey function.
- Finally, you will receive AuthResult with result == true if the correct password was specified.
Example backend function PHP:
Ruby:
Node.js:
Java(Spring):