title: Retrieving Google Authorization Code through OAuth2.0 in Java
body: <p>I am working on a desktop project that requires Google Authorization for Google Calendar API using OAuth2.0. The language used is java. </p>
  
  <p>Currently to authorize the project, I have to open the browser using java.swt.Desktop.getDesktop().browse(url), click the "accept" button, copy the authorization code in the redirected page and paste it in my application. And the user has to close the webpage manually. Quite troublesome. </p>
  
  <p>Is there a better, more user-friendly approach to achieve this authorization procedure? The ultimate procedure I want to achieve is only that the application opens the authorization page, the user clicks "accept", the page closes itself automatically and the software is authorized. I have seen this kind of procedure in other applications. It's just that I don't know how to achieve this. </p>
  
  <p>Thanks in advance. </p>