NATS Logo by Example

Authentication and Authorization

Programmatic NKeys and JWTs

The primary (and recommended) way to create and manage accounts and users is using the nsc command-line tool. However, in some applications and use cases, it may be desirable to programmatically create accounts or users on-demand as part of an application-level account/user workflow rather than out-of-band on the command line (however, shelling out to nsc from your program is another option).

This example shows how to programmatically generate NKeys and JWTs. This can be used as an alternative or, more likely, in conjunction with the nsc tool for creating and managing accounts and users.

Note, not all languages currently implement standalone NKeys or JWT libraries.

CLI Go Python JavaScript Rust C# Java Ruby Elixir Crystal C