code: private static Credential authenticate(String userId, SessionConfiguration config) throws Exception {
          OAuth2Credentials oAuth2Credentials = createOAuth2Credentials(config);
  
          // First try to load an existing Credential. If that credential is null, authenticate the user.
          Credential credential = oAuth2Credentials.loadCredential(userId);
          if (credential == null || credential.getAccessToken() == null) {
              // Send user to authorize your application.
              System.out.printf("Add the following redirect URI to your developer.uber.com application: %s%n",
                      oAuth2Credentials.getRedirectUri());
              System.out.println("Press Enter when done.");
  
              System.in.read();
  
              // Generate an authorization URL.
              String authorizationUrl = oAuth2Credentials.getAuthorizationUrl();
              System.out.printf("In your browser, navigate to: %s%n", authorizationUrl);
              System.out.println("Waiting for authentication...");
  
              // Wait for the authorization code.
              String authorizationCode = localServerReceiver.waitForCode();
              System.out.println("Authentication received.");
  
              // Authenticate the user with the authorization code.
              credential = oAuth2Credentials.authenticate(authorizationCode, userId);
          }
          localServerReceiver.stop();
  
          return credential;
      }
docs: Authenticate the given user. If you are distributing an installed application, this method
  should exist on your server so that the client ID and secret are not shared with the end
  user.