static SessionConfiguration createSessionConfiguration() throws IOException { // Load the client ID and secret from a secrets properties file. Properties secrets = loadSecretProperties(); String clientId = secrets.getProperty("clientId"); String clientSecret = secrets.getProperty("clientSecret"); if (clientId.equals("INSERT_CLIENT_ID_HERE") || clientSecret.equals("INSERT_CLIENT_SECRET_HERE")) { throw new IllegalArgumentException( "Please enter your client ID and secret in the resoures/secrets.properties file."); } return new SessionConfiguration.Builder() .setClientId(clientId) .setClientSecret(clientSecret) .setRedirectUri(REDIRECT_URI) .setScopes(Collections.singletonList(Scope.PROFILE)) .build(); }
public static SessionConfiguration createSessionConfiguration() throws Exception { // Load the client ID and secret from {@code resources/secrets.properties}. Ideally, your // secrets would not be kept local. Instead, have your server accept the redirect and return // you the accessToken for a userId. Properties secrets = loadSecretProperties(); String clientId = secrets.getProperty("clientId"); String clientSecret = secrets.getProperty("clientSecret"); if (clientId.equals("INSERT_CLIENT_ID_HERE") || clientSecret.equals("INSERT_CLIENT_SECRET_HERE")) { throw new IllegalArgumentException( "Please enter your client ID and secret in the resources/secrets.properties file."); } // Start a local server to listen for the OAuth2 redirect. localServerReceiver = new LocalServerReceiver.Builder().setPort(8181).build(); String redirectUri = localServerReceiver.getRedirectUri(); return new SessionConfiguration.Builder() .setClientId(clientId) .setClientSecret(clientSecret) .setRedirectUri(redirectUri) .build(); }