I have developed an github app which listens to merge event and provide analytics to the organization. App have user:read permission. To map git users with my app users we need an email id. I tried calling below API but it always gives email as null (may be these users don't have their email as public.) . How can we access the email irrespective of profile setting? . Is there any other way we I can map git user to our app users (we only have email and names of users)
Request req = new Request.Builder()
.url("https://api.github.com/user/emails" + userName)
.header("Authorization", "Bearer " + installationToken)
.get()
.build();
Response resp = client.newCall(req).execute();
String jsonResp2 = resp.body().string();
Map userDetail = gson.fromJson(jsonResp2, Map.class);
String email = userDetail.get("email").toString();