Skip to content

Latest commit

 

History

History
26 lines (14 loc) · 855 Bytes

File metadata and controls

26 lines (14 loc) · 855 Bytes

Authenticating with a Token

Tokens are basically random strings, much like a password, and can provide a simple authentication mechanism in some situations. However, tokens are only as safe as they are secret so other authentication schemes can provide more security in large installations.

For this example, start the server using:

> nats-server --auth mytoken

The code uses localhost:4222 so that you can start the server on your machine to try them out.

Connecting with a Token

!INCLUDE "../../_examples/connect_token.html"

Connecting with a Token in the URL

Some client libraries will allow you to pass the token as part of the server URL using the form:

nats://token@server:port

Again, once you construct this URL you can connect as if this was a normal URL.

!INCLUDE "../../_examples/connect_token_url.html"