I am using Google OAuth 2.0 for authentication of an installed desktop Java application. I am using the Google OAuth 2.0 Java Client Library.
When I make a call to request the user to authorize access to their Google Calendar, the “Request for Permission” webpage is displayed in the default browser, as expected. After the user clicks Cancel or Accept, the webpage displays the message:
Received verification code. Closing...
In Internet Explorer, the webpage is then closed. In Firefox and Chrome, however, the webpage remains open.
Is there a way to force the webpage to close (from my Java program)?
This is the code I am using that triggers the webpage (taken from the Google Developer's CalendarSample (http://samples.google-api-java-client.googlecode.com/hg-history/425c5ffc30178f21aea592bc989849ea7e3498fe/calendar-cmdline-sample/instructions.html):
// set up authorization code flow
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
httpTransport, JSON_FACTORY, clientSecrets,
Collections.singleton(CalendarScopes.CALENDAR)).setDataStoreFactory(dataStoreFactory)
.build();
// authorize
return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");