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(); }
@Test public void newBuilder_copiesConfiguration() throws Exception { SessionConfiguration config = new SessionConfiguration.Builder() .setClientId("clientId") .setRedirectUri("test") .build(); SessionConfiguration config2 = config.newBuilder().setClientId("clientId2").build(); assertEquals("clientId", config.getClientId()); assertEquals("clientId2", config2.getClientId()); assertEquals("test", config2.getRedirectUri()); }
public Builder newBuilder() { return new Builder() .setClientId(clientId) .setRedirectUri(redirectUri) .setEnvironment(environment) .setScopes(scopes); } }
@Test public void getRedirectUri_whenSetOnBuilder_setsOnConfiguration() throws Exception { SessionConfiguration config = new SessionConfiguration.Builder() .setClientId("clientId") .setRedirectUri("redirectUri") .build(); assertEquals("redirectUri", config.getRedirectUri()); }
public Builder newBuilder() { return new Builder() .setClientId(clientId) .setRedirectUri(redirectUri) .setEnvironment(environment) .setScopes(scopes); } }