File tree Expand file tree Collapse file tree 3 files changed +34
-3
lines changed
src/main/java/org/kohsuke/github Expand file tree Collapse file tree 3 files changed +34
-3
lines changed Original file line number Diff line number Diff line change 10
10
public class GHKey {
11
11
/*package almost final*/ GitHub root ;
12
12
13
- private String url , key , title ;
14
- private boolean verified ;
15
- private int id ;
13
+ protected String url , key , title ;
14
+ protected boolean verified ;
15
+ protected int id ;
16
16
17
17
public int getId () {
18
18
return id ;
Original file line number Diff line number Diff line change @@ -34,13 +34,31 @@ public List<String> getEmails() throws IOException {
34
34
/**
35
35
* Returns the read-only list of all the pulic keys of the current user.
36
36
*
37
+ * NOTE: When using OAuth authenticaiton, the READ/WRITE User scope is
38
+ * required by the GitHub APIs, otherwise you will get a 404 NOT FOUND.
39
+ *
37
40
* @return
38
41
* Always non-null.
39
42
*/
40
43
public List <GHKey > getPublicKeys () throws IOException {
41
44
return Collections .unmodifiableList (Arrays .asList (root .retrieve ().to ("/user/keys" , GHKey [].class )));
42
45
}
43
46
47
+ /**
48
+ * Returns the read-only list of all the pulic verified keys of the current user.
49
+ *
50
+ * Differently from the getPublicKeys() method, the retrieval of the user's
51
+ * verified public keys does not require any READ/WRITE OAuth Scope to the
52
+ * user's profile.
53
+ *
54
+ * @return
55
+ * Always non-null.
56
+ */
57
+ public List <GHVerifiedKey > getPublicVerifiedKeys () throws IOException {
58
+ return Collections .unmodifiableList (Arrays .asList (root .retrieve ().to (
59
+ "/users/" + getLogin () + "/keys" , GHVerifiedKey [].class )));
60
+ }
61
+
44
62
/**
45
63
* Gets the organization that this user belongs to.
46
64
*/
Original file line number Diff line number Diff line change
1
+ package org .kohsuke .github ;
2
+
3
+ public class GHVerifiedKey extends GHKey {
4
+
5
+ public GHVerifiedKey () {
6
+ this .verified = true ;
7
+ }
8
+
9
+ @ Override
10
+ public String getTitle () {
11
+ return (title == null ? "key-" + id : title );
12
+ }
13
+ }
You can’t perform that action at this time.
0 commit comments