AuthUtils { @NonNull static String buildUrl( @NonNull String redirectUri, @NonNull ResponseType responseType, @NonNull SessionConfiguration configuration) { final String CLIENT_ID_PARAM = "client_id"; final String ENDPOINT = "login"; final String HTTPS = "https"; final String PATH = "oauth/v2/authorize"; final String REDIRECT_PARAM = "redirect_uri"; final String RESPONSE_TYPE_PARAM = "response_type"; final String SCOPE_PARAM = "scope"; final String SHOW_FB_PARAM = "show_fb"; final String SIGNUP_PARAMS = "signup_params"; final String REDIRECT_LOGIN = "{\"redirect_to_login\":true}"; Uri.Builder builder = new Uri.Builder(); builder.scheme(HTTPS) .authority(ENDPOINT + "." + configuration.getEndpointRegion().getDomain()) .appendEncodedPath(PATH) .appendQueryParameter(CLIENT_ID_PARAM, configuration.getClientId()) .appendQueryParameter(REDIRECT_PARAM, redirectUri) .appendQueryParameter(RESPONSE_TYPE_PARAM, responseType.toString().toLowerCase( Locale.US)) .appendQueryParameter(SCOPE_PARAM, getScopes(configuration)) .appendQueryParameter(SHOW_FB_PARAM, "false") .appendQueryParameter(SIGNUP_PARAMS, AuthUtils.createEncodedParam(REDIRECT_LOGIN)); return builder.build().toString(); }  static boolean isRedirectUriRegistered(@NonNull Activity activity, @NonNull Uri uri); @NonNull static String scopeCollectionToString(@NonNull Collection<Scope> scopes); static String customScopeCollectionToString(@NonNull Collection<String> scopes); static String mergeScopeStrings(String... scopes);  }
@Test public void onBuildUrl_withDefaultRegion_shouldHaveDefaultUberDomain() { String clientId = "clientId1234"; String redirectUri = "localHost1234"; SessionConfiguration loginConfiguration = new SessionConfiguration.Builder() .setRedirectUri(redirectUri) .setScopes(Arrays.asList(Scope.HISTORY)) .setClientId(clientId) .build(); String url = AuthUtils.buildUrl(redirectUri, ResponseType.TOKEN, loginConfiguration); assertEquals("https: "&redirect_uri=" + redirectUri + "&response_type=token&scope=history&" + "show_fb=false&signup_params=eyJyZWRpcmVjdF90b19sb2dpbiI6dHJ1ZX0%3D%0A", url); }