Last active
January 29, 2019 23:22
-
-
Save stephenmenton/45acb8608aaf6e8f364977be6d506534 to your computer and use it in GitHub Desktop.
"upsert" api token, print the value
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
String userName = 'namehere' | |
String tokenName = 'namehere' | |
User user = User.get(userName) | |
ApiTokenProperty tokenProperty = user.getProperty(ApiTokenProperty.class) | |
tokenStore = tokenProperty.tokenStore | |
tokenStore.deleteAllLegacyTokens() // unneeded later | |
tokenStore.tokenList.removeAll { it.name == tokenName } | |
newToken = tokenStore.generateNewToken(tokenName) | |
println newToken.plainValue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment