There is a project on which authorization in Google services occurs through a redirect link that the application generates and allows you to log in to further work with Google services. Does anyone have a sample code in java, how to implement access to their services without a browser. I found the only link that answers my question - http://open-thoughts.net/article/read/11 , but there are some moments that are not clarified by this appeal to you. The example code for authorization is an example for .NET only.
UPD Now I use this method for authorization
private static Credential authorize() throws Exception { // load client secrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(OAuth2Sample.class.getResourceAsStream("/res/client_secret.json"))); if (clientSecrets.getDetails().getClientId().startsWith("Enter") || clientSecrets.getDetails().getClientSecret().startsWith("Enter ")) { System.out.println("Enter Client ID and Secret from https://code.google.com/apis/console/ " + "into oauth2-cmdline-sample/src/main/resources/client_secrets.json"); System.exit(1); } // set up authorization code flow GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder( httpTransport, JSON_FACTORY, clientSecrets, SCOPES).setAccessType("offline").setApprovalPrompt("force").build(); // authorize return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("my@email.com"); }
But when doing it, a redirect to the browser still happens, where permission for the application is displayed, how to get rid of the browser to solve this problem?