use of org.jetbrains.plugins.github.exceptions.GithubConfusingException in project intellij-community by JetBrains.
the class GithubApiUtil method getTokenScopes.
@NotNull
public static Collection<String> getTokenScopes(@NotNull GithubConnection connection) throws IOException {
Header[] headers = connection.headRequest("/user", ACCEPT_V3_JSON);
Header scopesHeader = null;
for (Header header : headers) {
if (header.getName().equals("X-OAuth-Scopes")) {
scopesHeader = header;
break;
}
}
if (scopesHeader == null) {
throw new GithubConfusingException("No scopes header");
}
Collection<String> scopes = new ArrayList<>();
for (HeaderElement elem : scopesHeader.getElements()) {
scopes.add(elem.getName());
}
return scopes;
}
Aggregations