Skip to content

Commit

Permalink
Merge pull request #2 from jofogas/create-server-token
Browse files Browse the repository at this point in the history
Add new function to create a server token
  • Loading branch information
zsadm authored Jun 27, 2024
2 parents 85bf5c5 + 8168e37 commit 4af649b
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 4af649b

Please sign in to comment.