-
-
Save cardoso/cc17ebb764602b1a474a7bc635d2db1f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func generateJWT(for userId: String) throws -> String { | |
struct StreamClaims: Claims { | |
let user_id: String | |
} | |
let myClaims = StreamClaims(user_id: userId) | |
var myJWT = JWT(claims: myClaims) | |
let key = "[my_secret]" | |
let keyData = key.data(using: .utf8)! | |
let signer = JWTSigner.hs256(key: keyData) | |
return try myJWT.sign(using: signer) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment