Created
February 23, 2020 22:09
-
-
Save naturalett/ccbcb162b9cc2cb5b15491b037a1ef53 to your computer and use it in GitHub Desktop.
getJsonWebToken
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
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