Skip to content

Commit

Permalink
Add new function to create a server token
Browse files Browse the repository at this point in the history
  • Loading branch information
zsadm authored Jun 27, 2024
1 parent 85bf5c5 commit 8168e37
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ func (c *Client) CreateToken(userID string, expire time.Time, issuedAt ...time.T
return c.createToken(claims)
}

// CreateServerToken creates a new server token
func (c *Client) CreateServerToken() (string, error) {
return c.createToken(jwt.MapClaims{"server": true})
}

func (c *Client) createToken(claims jwt.Claims) (string, error) {
return jwt.NewWithClaims(jwt.SigningMethodHS256, claims).SignedString(c.apiSecret)
}
Expand Down

0 comments on commit 8168e37

Please sign in to comment.