Great news!! We just added token based authentication on deepstreamHub. What this means is that you can now let the users of your application login using a token, thus not having to enter their credentials each time they wish to use your application.

A token is a unique piece of information used by your server as an alternative way of recognising you. It is essentially like your nickname which your friends might use instead of your full name for simplicity.

If you check out the "Auth" section of your deepstreamHub dashboard, you'll notice an additional option called token. Like always, you'll first need to enable it in the dashboard before being able to use it as an authentication mechanism in your application.

tokenauth

Just add a token there and don't forget to give it a name, as well as some client and server data.

addtoken

deepstream will use this information to generate a unique string which can now be used by the user to login into your application.

Logging in using token auth

Similar to the authentication mechanisms you have used until now, simply send this unique token as an auth parameter in the login method after establishing a connection with deepstream, as shown:

const client = deepstream('<YOUR APP URL>')

client.login({ token: '<UNIQUE TOKEN>' }, (success, data) => {
  if (success) {
    //handle sucess
  } else {
    //handle error
  }
})

That's it! You now have all the information you need to start using tokens. :D

If you would like to explore all the deepstream's existing authentication methods, just take a stroll through this page.