How to obtain GitHub user name?

Answered

I want to get this name by code. What should I do?

0
3 comments

Can you provide more information about what you're trying to do? Are you trying to get the GitHub name from the user in your plugin? Are you you trying to get user information from the GitHub API?

0

Yes, I want to read the user's GitHub information in the plug-in. I use this method now, but I want to know whether there is a simpler API to use

public static String readGithubName() {
String cmd="git config user.name";
String line;
StringBuilder sb = new StringBuilder();
Runtime runtime = Runtime.getRuntime();
try {
Process process = runtime.exec(cmd);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
while ((line = bufferedReader.readLine()) != null) {
sb.append(line);
}
return sb.toString();
} catch (Exception e) {
return "null";
}
}
0

Just now, I found it

org.jetbrains.plugins.github.authentication.accounts.GHAccountManager
0

Please sign in to leave a comment.