简体   繁体   中英

Authenticating google drive with a java application using a local web server

Towards the end of this video they talk about using a local web server to 'catch' the redirect from the oauth login web page.

I'd really like to implement something like this in a java app I am writing (not a web app).

At the moment I launch a web browser from my app to the login page and I understand that if I set the redirect uri to localhost then the code will be sent to a local web server.

My questions are

  1. What webserver should I use? I only need it to 'catch' this one redirect and return the code so it should be as small as possible. Is it possible to do this within my app or would I need to launch a separate program.

  2. How can I get the code back from the web server?

  3. Are there any examples of this being done that I have missed?

Thanks for any advice you could give.

There is an example of you want : Drive command line sample

Basically, google redirects the user after he has granted the access rights to your web server. In the case of this example, the server is a Jetty server which handles GET requests with a servlet.

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