Hi guys, im starting to programing with this API and i want to make an Android apk, but first i try the code i want to use in Java mode. I was able to get some information with the API but the problem was when i try to get de Subscribers of an User. After searching i discover that i have to make an Authentication page, so i do the following:
1- Download this https://github.com/mb3364/Java-Twitch-Api-Wrapper and using it as a Lib.
2- Test this simple code to make sure im doing a good work:
Twitch twitch = new Twitch();
twitch.setClientId("Myid");
URI callbackUri = null;
try {
callbackUri = new URI("http://127.0.0.1:23522/token/");
} catch (URISyntaxException e) {
e.printStackTrace();
}
String authUrl = twitch.auth().getAuthenticationUrl(twitch.getClientId(), callbackUri, Scopes.USER_READ);
System.out.println(authUrl);
try {
String url = authUrl + "&force_verify=true";
java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
} catch (java.io.IOException e) {
System.out.println(e.getMessage());
}
boolean authSuccess = twitch.auth().awaitAccessToken();
if (authSuccess) {
String accessToken = twitch.auth().getAccessToken();
System.out.println("Access Token: " + accessToken);
} else {
System.out.println(twitch.auth().getAuthenticationError());
}
But the problem is that i never reach that final If because is always waiting.
Any help will be welcome.
Thanks for the help.