Skip to content

stuckinforloop/jwt-codegen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JWT Code Generator

This project generates JWT (JSON Web Token) code from a JSON config file.

Usage Create a config.json file with your custom claims defined. For example:

{
  "issuer": "Example Inc.",
  "audience": "Example API Users"
}

Run go run main.go. This will generate a jwt.go file with a JWT struct based on your config.

Use the generated jwt.go file in your code to create JWT tokens with your custom claims. For example:

import "github.com/stuckinforloop/jwt-codegen/jwt"

func main() {
  // Create token
  token := jwt.NewJWT()
  token.Issuer = "Example Inc."
  token.Audience = "Example API Users"
  tokenString, err := token.SignedString("secret")
  
  // Parse token
  parsedToken, err := jwt.Parse(tokenString, "secret")
}

The generated struct will have getter and setter methods for each claim, as well as SignedString() and Parse() methods to sign and parse the tokens.

About

JWT Code Generator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages