Исключение для Android API домена плюс
Я пытаюсь получить круги пользователя, используя Google Plus Domain API Android.
Сначала я импортировал следующие библиотеки в свой проект:
google-api-client-1.18.0-rc.jar
google-api-client-android-1.18.0-rc.jar
google-oauth-client-1.18.0-rc.jar
google-http-client-1.18.0-rc.jar
google-http-client-android-1.18.0-rc.jar
gson-2.1.jar
jackson-core-asl-1.9.11.jar
jackson-core-2.1.3.jar
jsr305-1.3.9.jar
protobuf-java-2.4.1.jar
Пожалуйста, найдите ссылку для получения дополнительной информации.
Я сделал следующие шаги:
Получить токен аутентификации:
String accountName = params[0]; String GPLUS_PROFILE = "https://www.googleapis.com/auth/userinfo.profile"; String GPLUS_LOGIN = "https://www.googleapis.com/auth/plus.login"; String GPLUS_CIRCLES = "https://www.googleapis.com/auth/plus.circles.read"; String GPLUS_ME = "https://www.googleapis.com/auth/plus.me"; String scopes = "oauth2:" + GPLUS_PROFILE + " " + GPLUS_LOGIN + " " + GPLUS_CIRCLES + " " + GPLUS_ME; String token = null; try { token = GoogleAuthUtil.getToken(LoginActivity.this, accountName, scopes); return token; } catch (IOException e) { Log.e(TAG, e.getMessage()); } catch (UserRecoverableAuthException e) { startActivityForResult(e.getIntent(), REQ_SIGN_IN_REQUIRED); return null; } catch (GoogleAuthException e) { Log.e(TAG, e.getMessage()); }
Теперь, когда я получил токен аутентификации, я попытался создать объект класса PlusDomain, чтобы получить подробную информацию о пользователе:
public void getPlusDomain(String response) { HttpTransport httpTransport = new NetHttpTransport(); JsonFactory jsonFactory = new JacksonFactory(); GoogleCredential googleCredential = new GoogleCredential() .setAccessToken(response); plusDomains = new PlusDomains.Builder(httpTransport, jsonFactory, googleCredential).setApplicationName("Google Mini") .build(); Person mePerson; try { mePerson = plusDomains.people().get("me").execute(); System.out.println("ID:\t" + mePerson.getId()); System.out.println("Display Name:\t" + mePerson.getDisplayName()); System.out.println("Image URL:\t" + mePerson.getImage().getUrl()); System.out.println("Profile URL:\t" + mePerson.getUrl()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Я получаю следующее исключение:
Я использовал эту ссылку, чтобы решить проблему, и исключение идет
JsonFactory jsonFactory = new JacksonFactory();
Thread.currentThread().setContextClassLoader(
jsonFactory.getClass().getClassLoader());
Однако после этого я получаю
com.google.api.client.googleapis.json.GoogleJsonResponseException
Как решить эту проблему и почему это исключение