Skip to content

Instantly share code, notes, and snippets.

@creativepsyco
Created August 27, 2014 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creativepsyco/3c08030fe3b31b4c7961 to your computer and use it in GitHub Desktop.
Save creativepsyco/3c08030fe3b31b4c7961 to your computer and use it in GitHub Desktop.
useful gist to clean up tokens from the log string
private static String stripTokens(String log) {
if (HIDE_TOKENS) {
/* Common REGEX patterns for replacing tokens */
log = log.replaceAll("token=\\S*", "token=ACCESS_TOKEN_REMOVED ");
log = log.replaceAll("client_secret=\\S*", "client_secret=CLIENT_SECRET_REMOVED ");
log = log.replaceAll("access_token=\\S*", "access_token=ACCESS_TOKEN_REMOVED ");
log = log.replaceAll("code=\\S*", "code=SOME_CODE_REMOVED ");
}
return log;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment