public static Credential authorize(final NetHttpTransport httpTransport) throws IOException { InputStream in = new FileInputStream(CLIENT_SECRETS); GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in)); GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(httpTransport, JSON_FACTORY, clientSecrets, SCOPES) .setAccessType("offline") .build(); int defaultPort = 5005; LocalServerReceiver customReceiver = new LocalServerReceiver.Builder() .setHost("localhost") .setPort(defaultPort) .build(); Credential credential = new AuthorizationCodeInstalledApp(flow, customReceiver).authorize("userid"); return credential;}public static YouTube getService() throws GeneralSecurityException, IOException { final NetHttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport(); Credential credential = authorize(httpTransport); return new YouTube.Builder(httpTransport, JSON_FACTORY, credential) .setApplicationName(APPLICATION_NAME) .build();}
So Everything works for me but i need to login everytime which I would prefer not doing. Is it possible to modify the code or anything else so it does that automaticly with given Email and password?