Skip to content

Instantly share code, notes, and snippets.

@naturalett
Created February 23, 2020 22:09
Show Gist options
  • Save naturalett/ccbcb162b9cc2cb5b15491b037a1ef53 to your computer and use it in GitHub Desktop.
Save naturalett/ccbcb162b9cc2cb5b15491b037a1ef53 to your computer and use it in GitHub Desktop.
getJsonWebToken
APP_ID = <APP_ID>
def getJsonWebToken(privateKey) {
try {
privateCrtKey = getRSAPrivateKey(privateKey)
time = accessTime()
def jsonWebToken = Jwts.builder()
.setSubject("RS256")
.signWith(RS256, privateCrtKey)
.setExpiration(time['expirationTime'])
.setIssuedAt(time['iat'])
.setIssuer(APP_ID)
.compact()
return jsonWebToken
} catch(Exception e){
echo "Exception: ${e}"
error "Failed to create a JWT"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment