Created
February 23, 2020 22:19
-
-
Save naturalett/120f014d1cf21be737f80c8206a01522 to your computer and use it in GitHub Desktop.
validateAuth
This file contains hidden or 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
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