Пробовал получить токен и просто вывести его, но почему то не работает. В чем может быть ошибка?
public class Token {
private final String response_type;
private String access_token;
private final String client_id;
public Token() {
this.response_type = "token";
this.client_id = "a42b1aed99284cb3a62f4d57f2392385";
}
public void setConnection() throws IOException, URISyntaxException {
//код получения token'a
HttpClient httpClient = new DefaultHttpClient();
HttpPost post = new HttpPost("https://oauth.yandex.ru/authorize?" +
"response_type="+response_type+
"&client_id="+client_id);
HttpResponse response;
response = httpClient.execute(post);
post.abort();
String HeaderLocation = response.getFirstHeader("location").getValue();
URI RedirectUri = new URI(HeaderLocation);
HeaderLocation = response.getFirstHeader("location").getValue();
// Проходим по нему
post = new HttpPost(HeaderLocation);
response = httpClient.execute(post);
post.abort();
HeaderLocation = response.getFirstHeader("location").getValue();
access_token = HeaderLocation.split("#")[1].split("&")[0].split("=")[1];
System.out.println(access_token);
}
public static void main(String[] args) throws IOException, URISyntaxException, AWTException, InterruptedException, NoSuchAlgorithmException {
Token yandexAPI = new Token();
yandexAPI.setConnection();
}
}
Ошибка при компиляции:
Exception in thread "main" org.apache.commons.logging.LogConfigurationException: No suitable Log implementation
at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:918)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:604)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:336)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:310)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:686)
at org.apache.http.impl.client.CloseableHttpClient.(CloseableHttpClient.java:60)
at org.apache.http.impl.client.AbstractHttpClient.(AbstractHttpClient.java:271)
at org.apache.http.impl.client.DefaultHttpClient.(DefaultHttpClient.java:146)
at oblako.Token.setConnection(Token.java:41)
at oblako.Token.main(Token.java:64)
Java Result: 1