CredentialsSession session = new CredentialsSession(config, credential);
public static void main(String[] args) throws Exception { // Create or load a credential for the user. SessionConfiguration config = createSessionConfiguration(); Credential credential = authenticate(System.getProperty("user.name"), config); //Create an authenticator for Credential to use in our Session CredentialsSession session = new CredentialsSession(config, credential); // Create the Uber API service object once the User is authenticated UberRidesApi uberRidesApi = UberRidesApi.with(session).build(); RidesService service = uberRidesApi.createService(); // Fetch the user's profile. System.out.println("Calling API to get the user's profile"); Response<UserProfile> response = service.getUserProfile().execute(); ApiError apiError = ErrorParser.parseError(response); if (apiError != null) { // Handle error. ClientError clientError = apiError.getClientErrors().get(0); System.out.printf("Unable to fetch profile. %s", clientError.getTitle()); System.exit(0); return; } // Success! UserProfile userProfile = response.body(); System.out.printf("Logged in as %s%n", userProfile.getEmail()); System.exit(0); }