Skip to content

Instantly share code, notes, and snippets.

@naturalett
Created February 23, 2020 22:19
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 naturalett/120f014d1cf21be737f80c8206a01522 to your computer and use it in GitHub Desktop.
Save naturalett/120f014d1cf21be737f80c8206a01522 to your computer and use it in GitHub Desktop.
validateAuth
def validateAuth(jsonWebToken) {
try {
def httpConn = new URL("https://api.github.com/app").openConnection();
httpConn.setRequestProperty( 'Authorization', "Bearer ${jsonWebToken}" )
httpConn.setRequestProperty( 'Accept', 'application/vnd.github.machine-man-preview+json' )
return httpConn.getResponseCode();
} catch(Exception e){
echo "Exception: ${e}"
error "Authentication request failed"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment