code: public static OAuth2Credentials createOAuth2Credentials(SessionConfiguration sessionConfiguration) throws Exception {
  
  
  
  
          // Store the users OAuth2 credentials in their home directory.
          File credentialDirectory =
                  new File(System.getProperty("user.home") + File.separator + ".uber_credentials");
          credentialDirectory.setReadable(true, true);
          credentialDirectory.setWritable(true, true);
          // If you'd like to store them in memory or in a DB, any DataStoreFactory can be used.
          AbstractDataStoreFactory dataStoreFactory = new FileDataStoreFactory(credentialDirectory);
  
          // Build an OAuth2Credentials object with your secrets.
          return new OAuth2Credentials.Builder()
                  .setCredentialDataStoreFactory(dataStoreFactory)
                  .setRedirectUri(sessionConfiguration.getRedirectUri())
                  .setClientSecrets(sessionConfiguration.getClientId(), sessionConfiguration.getClientSecret())
                  .build();
      }
docs: Creates an {@link OAuth2Credentials} object that can be used by any of the servlets.