【问题标题】:Google Drive Access using AuthSubUtil.exchangeForSessionToken使用 AuthSubUtil.exchangeForSessionToken 访问 Google 云端硬盘
【发布时间】:2012-07-12 05:15:33
【问题描述】:

在 Google AppEngine 上,我已通过 Google Docs 的身份验证...使用 AuthSub authshub 访问。

我们设法AuthSubUtil.exchangeForSessionToken(..)

问题:是否可以使用此令牌跟进并获得对 Google Drive 的访问权限?

... new Drive.Builder(httpTransport, jsonFactory, credential);

【问题讨论】:

    标签: google-app-engine google-apps google-drive-api google-apps-marketplace


    【解决方案1】:

    我不确定 AuthSub 是否适用于 Google Drive API,但如果可以,此代码 sn-p 应该可以解决您的问题:

    new Drive.Builder(httpTransport, jsonFactory, new HttpRequestInitializer() {
      @Override
      public void initialize(HttpRequest request) {
        HttpHeaders headers = request.getHeaders();
        // Not sure if this test is necessary as headers might never be null.
        if (headers == null) {
          headers = new HttpHeaders();
          request.setHeaders(headers);
        }
        headers.setAuthorization("AuthSub token=\"<TOKEN>\"");
      }
    }).build();
    

    重要提示:请注意 AuthSub 已被弃用,您应该尽快迁移您的应用程序以使用 OAuth 2.0。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多