【问题标题】:Google Drive authentication in GWTGWT 中的 Google Drive 身份验证
【发布时间】:2013-10-01 15:08:43
【问题描述】:

我正在尝试实现这个例子,

https://google-developers.appspot.com/drive/auth/web-server

但是没有找到以下类! Oauth2, Userinfo

  static User getUserInfo(Credential credentials)
      throws NoUserIdException {
    Oauth2 userInfoService =
        new Oauth2.Builder(new NetHttpTransport(), new JacksonFactory(), credentials).build();
    Userinfo userInfo = null;
    try {
      userInfo = userInfoService.userinfo().get().execute();
    } catch (IOException e) {
      System.err.println("An error occurred: " + e);
    }
    if (userInfo != null && userInfo.getId() != null) {
      return userInfo;
    } else {
      throw new NoUserIdException();
    }
  }

找到所有其他类。我的构建路径 (Eclipse) 中有最新的 Drive 库。

这个例子很混乱。我以前实现过 OAuth,这太冗长和过于复杂了。用户被发送到 Google 进行身份验证的位置甚至都不明显。

【问题讨论】:

    标签: java gwt google-drive-api google-oauth


    【解决方案1】:

    必须添加

    https://developers.google.com/api-client-library/java/apis/oauth2/v2

    Drive SDK 有com.google.api.client.auth.oauth2,但没有com.google.api.services.oauth2!算了!

    它仍然不起作用。

    类型不匹配:无法从 Userinfo 转换为 User

    所以我不得不将返回类型更改为 Userinfo。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-29
      • 1970-01-01
      相关资源
      最近更新 更多