List of usage examples for com.squareup.okhttp HttpUrl parse
public static HttpUrl parse(String url)
From source file:com.auth0.android.Auth0Test.java
License:Open Source License
@Test public void shouldBuildWithClientIdAndDomain() throws Exception { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); assertThat(auth0.getClientId(), equalTo(CLIENT_ID)); assertThat(HttpUrl.parse(auth0.getDomainUrl()), equalTo(HttpUrl.parse("https://samples.auth0.com"))); assertThat(HttpUrl.parse(auth0.getConfigurationUrl()), equalTo(HttpUrl.parse("https://cdn.auth0.com"))); }
From source file:com.auth0.android.Auth0Test.java
License:Open Source License
@Test public void shouldBuildWithConfigurationDomainToo() throws Exception { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN, CONFIG_DOMAIN_CUSTOM); assertThat(auth0.getClientId(), equalTo(CLIENT_ID)); assertThat(HttpUrl.parse(auth0.getDomainUrl()), equalTo(HttpUrl.parse("https://samples.auth0.com"))); assertThat(HttpUrl.parse(auth0.getConfigurationUrl()), equalTo(HttpUrl.parse("https://config.mydomain.com"))); }
From source file:com.auth0.android.Auth0Test.java
License:Open Source License
@Test public void shouldHandleEUInstance() throws Exception { Auth0 auth0 = new Auth0(CLIENT_ID, EU_DOMAIN); assertThat(auth0.getClientId(), equalTo(CLIENT_ID)); assertThat(HttpUrl.parse(auth0.getDomainUrl()), equalTo(HttpUrl.parse("https://samples.eu.auth0.com"))); assertThat(HttpUrl.parse(auth0.getConfigurationUrl()), equalTo(HttpUrl.parse("https://cdn.eu.auth0.com"))); }
From source file:com.auth0.android.Auth0Test.java
License:Open Source License
@Test public void shouldHandleAUInstance() throws Exception { Auth0 auth0 = new Auth0(CLIENT_ID, AU_DOMAIN); assertThat(auth0.getClientId(), equalTo(CLIENT_ID)); assertThat(HttpUrl.parse(auth0.getDomainUrl()), equalTo(HttpUrl.parse("https://samples.au.auth0.com"))); assertThat(HttpUrl.parse(auth0.getConfigurationUrl()), equalTo(HttpUrl.parse("https://cdn.au.auth0.com"))); }
From source file:com.auth0.android.Auth0Test.java
License:Open Source License
@Test public void shouldHandleOtherInstance() throws Exception { Auth0 auth0 = new Auth0(CLIENT_ID, OTHER_DOMAIN); assertThat(auth0.getClientId(), equalTo(CLIENT_ID)); assertThat(HttpUrl.parse(auth0.getDomainUrl()), equalTo(HttpUrl.parse("https://samples-test.other-subdomain.other.auth0.com"))); assertThat(HttpUrl.parse(auth0.getConfigurationUrl()), equalTo(HttpUrl.parse("https://cdn.other.auth0.com"))); }
From source file:com.auth0.android.Auth0Test.java
License:Open Source License
@Test public void shouldHandleNonAuth0Domain() throws Exception { Auth0 auth0 = new Auth0(CLIENT_ID, "mydomain.com"); assertThat(auth0.getClientId(), equalTo(CLIENT_ID)); assertThat(HttpUrl.parse(auth0.getDomainUrl()), equalTo(HttpUrl.parse("https://mydomain.com"))); assertThat(HttpUrl.parse(auth0.getConfigurationUrl()), equalTo(HttpUrl.parse("https://mydomain.com"))); }
From source file:com.auth0.android.Auth0Test.java
License:Open Source License
@Test public void shouldReturnAuthorizeUrl() throws Exception { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); final HttpUrl url = HttpUrl.parse(auth0.getAuthorizeUrl()); assertThat(url, hasScheme("https")); assertThat(url, hasHost(DOMAIN));//from w w w.ja va2 s .c om assertThat(url, hasPath("authorize")); }
From source file:com.auth0.android.authentication.AuthenticationAPIClient.java
License:Open Source License
/** * Log in a user with a OAuth 'access_token' of a Identity Provider like Facebook or Twitter using <a href="https://auth0.com/docs/api/authentication#social-with-provider-s-access-token">'\oauth\access_token' endpoint</a> * The default scope used is 'openid'.//w ww. j av a 2 s . c o m * Example usage: * <pre> * {@code * client.loginWithOAuthAccessToken("{token}", "{connection name}") * .start(new BaseCallback<Credentials>() { * {@literal}Override * public void onSuccess(Credentials payload) { } * * {@literal}Override * public void onFailure(AuthenticationException error) { } * }); * } * </pre> * * @param token obtained from the IdP * @param connection that will be used to authenticate the user, e.g. 'facebook' * @return a request to configure and start that will yield {@link Credentials} */ @SuppressWarnings("WeakerAccess") public AuthenticationRequest loginWithOAuthAccessToken(@NonNull String token, @NonNull String connection) { HttpUrl url = HttpUrl.parse(auth0.getDomainUrl()).newBuilder().addPathSegment(OAUTH_PATH) .addPathSegment(ACCESS_TOKEN_PATH).build(); Map<String, Object> parameters = ParameterBuilder.newAuthenticationBuilder().setClientId(getClientId()) .setConnection(connection).setAccessToken(token).asDictionary(); return factory.authenticationPOST(url, client, gson).addAuthenticationParameters(parameters); }
From source file:com.auth0.android.authentication.AuthenticationAPIClient.java
License:Open Source License
/** * Fetch the token information from Auth0. * Example usage:/*ww w .j ava 2 s .c o m*/ * <pre> * {@code * client.tokenInfo("{id_token}") * .start(new BaseCallback<UserProfile>() { * {@literal}Override * public void onSuccess(UserProfile payload) { } * * {@literal}@Override * public void onFailure(AuthenticationException error) { } * }); * } * </pre> * * @param idToken used to fetch it's information * @return a request to start * @deprecated Please use {@link AuthenticationAPIClient#userInfo(String)} instead. */ @SuppressWarnings("WeakerAccess") @Deprecated public Request<UserProfile, AuthenticationException> tokenInfo(@NonNull String idToken) { HttpUrl url = HttpUrl.parse(auth0.getDomainUrl()).newBuilder().addPathSegment(TOKEN_INFO_PATH).build(); return factory.POST(url, client, gson, UserProfile.class, authErrorBuilder).addParameter(ID_TOKEN_KEY, idToken); }
From source file:com.auth0.android.authentication.AuthenticationAPIClient.java
License:Open Source License
/** * Creates a user in a DB connection using <a href="https://auth0.com/docs/api/authentication#signup">'/dbconnections/signup' endpoint</a> * Example usage:// ww w. j a va2 s .c om * <pre> * {@code * client.createUser("{email}", "{password}", "{username}", "{database connection name}") * .start(new BaseCallback<DatabaseUser>() { * {@literal}Override * public void onSuccess(DatabaseUser payload) { } * * {@literal}@Override * public void onFailure(AuthenticationException error) { } * }); * } * </pre> * * @param email of the user and must be non null * @param password of the user and must be non null * @param username of the user and must be non null * @param connection of the database to create the user on * @return a request to start */ @SuppressWarnings("WeakerAccess") public DatabaseConnectionRequest<DatabaseUser, AuthenticationException> createUser(@NonNull String email, @NonNull String password, @NonNull String username, @NonNull String connection) { HttpUrl url = HttpUrl.parse(auth0.getDomainUrl()).newBuilder().addPathSegment(DB_CONNECTIONS_PATH) .addPathSegment(SIGN_UP_PATH).build(); final Map<String, Object> parameters = ParameterBuilder.newBuilder().set(USERNAME_KEY, username) .set(EMAIL_KEY, email).set(PASSWORD_KEY, password).setConnection(connection) .setClientId(getClientId()).asDictionary(); final ParameterizableRequest<DatabaseUser, AuthenticationException> request = factory .POST(url, client, gson, DatabaseUser.class, authErrorBuilder).addParameters(parameters); return new DatabaseConnectionRequest<>(request); }