简体   繁体   中英

google drive java in the cloud

I followed this tutorial on how to connect to google drive. I took some liberty with using maven instead of gradle and a few details, but it worked. I inserted the relevant code into war file and deployed it in my localhost and it worked on the server. However, when I deployed the same war into google compute engine, it didn't work. 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. I would expect there to be a way to deploy such a solution on web server, but I did not find it.

I think about moving my authorization to JS, and pass the token to backend, but that does not seem a good practise for me.

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).

Weird it was nowhere in the google tutorials. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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