From 75b9184a0011a5d900698e1d119105b2543a5047 Mon Sep 17 00:00:00 2001 From: Ruben Dijkstra Date: Fri, 9 Oct 2015 12:31:08 +0200 Subject: [PATCH] Check builder result to either be a token or a user Currently, a `user` property is always required (it not having content is also fine). This adds support for only having the `oauth` key in the property file/environment. --- src/main/java/org/kohsuke/github/GitHubBuilder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GitHubBuilder.java b/src/main/java/org/kohsuke/github/GitHubBuilder.java index c0ecaffda5..9160976640 100644 --- a/src/main/java/org/kohsuke/github/GitHubBuilder.java +++ b/src/main/java/org/kohsuke/github/GitHubBuilder.java @@ -51,7 +51,7 @@ public static GitHubBuilder fromCredentials() throws IOException { try { builder = fromPropertyFile(); - if (builder.user != null) + if (builder.oauthToken != null || builder.user != null) return builder; } catch (FileNotFoundException e) { // fall through @@ -60,7 +60,7 @@ public static GitHubBuilder fromCredentials() throws IOException { builder = fromEnvironment(); - if (builder.user != null) + if (builder.oauthToken != null || builder.user != null) return builder; else throw (IOException)new IOException("Failed to resolve credentials from ~/.github or the environment.").initCause(cause);