使用GWT Google Picker将图像上载到Google Drive

使用GWT Google Picker将图像上载到Google Drive,gwt,google-drive-api,google-picker,Gwt,Google Drive Api,Google Picker,我正在尝试使用Google Picker用户界面将图像上传到Google Drive。到目前为止,我一直没有成功 这是我正在使用的代码: private void onCreatePicker(ViewId viewId) { final Picker picker = PickerBuilder.create() .setTitle("Subir imagen a Google Drive") .addV

我正在尝试使用Google Picker用户界面将图像上传到Google Drive。到目前为止,我一直没有成功

这是我正在使用的代码:

private void onCreatePicker(ViewId viewId) {

    final Picker picker = PickerBuilder.create()                
            .setTitle("Subir imagen a Google Drive")
            .addView(viewId)
            .addView(DocsUploadView())
            .setLocale("es")                
            .setOAuthToken(token_oauth2)
            .setDeveloperKey(DEVELOPER_KEY)
            .setCallback(buildPickerCallback(viewId))
            .build();
    picker.setVisible(true);
  }

private JavaScriptObject DocsUploadView() {
    return com.ip.gae.gartla.shared.DocsUploadView.create();

}
我请求你的帮助,我会错过什么

谢谢你抽出时间

问候,

更新:看来我的应用范围错了。为了生成正确的oAuth2Token,必须声明要为其生成令牌的范围:

以下是我用来生成令牌的方法:

private void tokenOauth2() {
    AuthRequest req = new AuthRequest(AUTH_URL, CLIENT_ID)
    .withScopes(GOOGLE_DRIVE_SCOPE); // Can specify multiple scopes here

    Auth.get().login(req, new Callback<String, Throwable>() {
          @Override
          public void onSuccess(String token) {
            token_oauth2 = token;
          }
          @Override
          public void onFailure(Throwable caught) {
            // The authentication process failed for some reason, see caught.getMessage()
          }
        });
}
所以,现在这对我来说是可行的。我已附上解决方案,因此如果有人发现它足够有趣。:-)

String GOOGLE_DRIVE_SCOPE = "https://www.googleapis.com/auth/drive";