简体   繁体   English

谷歌驱动器云中的Java

[英]google drive java in the cloud

I followed this tutorial on how to connect to google drive. 我按照本教程介绍了如何连接到Google Drive。 I took some liberty with using maven instead of gradle and a few details, but it worked. 我使用了maven而不是gradle和一些细节,但这样做还是可以的。 I inserted the relevant code into war file and deployed it in my localhost and it worked on the server. 我将相关代码插入war文件,并将其部署在本地主机中,并在服务器上工作。 However, when I deployed the same war into google compute engine, it didn't work. 但是,当我将相同的战役部署到Google计算引擎中时,它没有起作用。 Obviously it is because of this line. 显然是因为这条线。

    Credential credential = new AuthorizationCodeInstalledApp(
        flow, new LocalServerReceiver()).authorize("user");

I guess it invokes the authorization procedure on the machine of the tomcat, not user. 我猜想它会在tomcat的计算机上而不是用户调用授权程序。 I would expect there to be a way to deploy such a solution on web server, but I did not find it. 我希望有一种方法可以在Web服务器上部署这样的解决方案,但是我没有找到它。

I think about moving my authorization to JS, and pass the token to backend, but that does not seem a good practise for me. 我考虑将授权转移到JS,并将令牌传递给后端,但这对我来说不是一个好习惯。

Regards 问候

I kept digging in the Internet for a while and found class com.google.api.client.extensions.servlet.auth.oauth2.AbstractAuthorizationCodeServlet (and AbstractAuthorizationCodeCallbackServlet from the same package). 我一直在Internet上搜索一段时间,并发现了com.google.api.client.extensions.servlet.auth.oauth2.AbstractAuthorizationCodeServlet类(和同一包中的AbstractAuthorizationCodeCallbackServlet)。

Weird it was nowhere in the google tutorials. 奇怪的是,它在Google教程中无处可寻。 It is quite close to what I need, so I keep working on it. 它与我的需求非常接近,因此我会继续努力。 For everyone interested in the matter: It seems that google authorizations don't like external IP addresses, so I need to set up domain properly, but that is another story. 对于对此事感兴趣的每个人:似乎Google授权不喜欢外部IP地址,因此我需要正确设置域,但这是另一回事了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM