// Set a token
nc, err := nats.Connect("127.0.0.1", nats.Name("API Token Example"), nats.Token("mytoken"))
if err != nil {
log.Fatal(err)
}
defer nc.Close()
// Do something with the connection
Options options = new Options.Builder().
server("nats://localhost:4222").
token("mytoken"). // Set a token
build();
Connection nc = Nats.connect(options);
// Do something with the connection
nc.close();
let nc = NATS.connect({url: `nats://127.0.0.1:${port}`, token: "mytoken!"});
nc = NATS()
await nc.connect(servers=["nats://mytoken@demo.nats.io:4222"])
# Do something with the connection.
NATS.start(token: "deadbeef") do |nc|
puts "Connected using token"
end
let nc = await connect({url: server.nats, token: "mytoken"});