@@ -57,6 +57,20 @@ public class AuthenticationAPIClient {
5757 private static final String REFRESH_TOKEN_KEY = "refresh_token" ;
5858
5959 private static final String PHONE_NUMBER_KEY = "phone_number" ;
60+ private static final String ACCESS_TOKEN_PATH = "access_token" ;
61+ private static final String SMS_CONNECTION = "sms" ;
62+ private static final String EMAIL_CONNECTION = "email" ;
63+ private static final String SIGN_UP_PATH = "signup" ;
64+ private static final String DB_CONNECTIONS_PATH = "dbconnections" ;
65+ private static final String CHANGE_PASSWORD_PATH = "change_password" ;
66+ private static final String UNLINK_PATH = "unlink" ;
67+ private static final String USER_ID_KEY = "user_id" ;
68+ private static final String DELEGATION_PATH = "delegation" ;
69+ private static final String PASSWORDLESS_PATH = "passwordless" ;
70+ private static final String START_PATH = "start" ;
71+ private static final String OAUTH_PATH = "oauth" ;
72+ private static final String RESOURCE_OWNER_PATH = "ro" ;
73+ private static final String TOKEN_INFO_PATH = "tokeninfo" ;
6074
6175 private final Auth0 auth0 ;
6276 private final OkHttpClient client ;
@@ -148,8 +162,8 @@ public AuthenticationRequest login(String usernameOrEmail, String password) {
148162 */
149163 public AuthenticationRequest loginWithOAuthAccessToken (String token , String connection ) {
150164 HttpUrl url = HttpUrl .parse (auth0 .getDomainUrl ()).newBuilder ()
151- .addPathSegment ("oauth" )
152- .addPathSegment ("access_token" )
165+ .addPathSegment (OAUTH_PATH )
166+ .addPathSegment (ACCESS_TOKEN_PATH )
153167 .build ();
154168
155169 Map <String , Object > parameters = ParameterBuilder .newBuilder ()
@@ -177,7 +191,7 @@ public AuthenticationRequest loginWithPhoneNumber(String phoneNumber, String ver
177191 .set (PASSWORD_KEY , verificationCode )
178192 .setGrantType (GRANT_TYPE_PASSWORD )
179193 .setClientId (getClientId ())
180- .setConnection ("sms" )
194+ .setConnection (SMS_CONNECTION )
181195 .asDictionary ();
182196 return newAuthenticationRequest (parameters );
183197 }
@@ -195,7 +209,7 @@ public AuthenticationRequest loginWithEmail(String email, String verificationCod
195209 .set (PASSWORD_KEY , verificationCode )
196210 .setGrantType (GRANT_TYPE_PASSWORD )
197211 .setClientId (getClientId ())
198- .setConnection ("email" )
212+ .setConnection (EMAIL_CONNECTION )
199213 .asDictionary ();
200214 return newAuthenticationRequest (parameters );
201215 }
@@ -222,8 +236,8 @@ public Request<UserProfile> tokenInfo(String idToken) {
222236 */
223237 public ParameterizableRequest <DatabaseUser > createUser (String email , String password , String username ) {
224238 HttpUrl url = HttpUrl .parse (auth0 .getDomainUrl ()).newBuilder ()
225- .addPathSegment ("dbconnections" )
226- .addPathSegment ("signup" )
239+ .addPathSegment (DB_CONNECTIONS_PATH )
240+ .addPathSegment (SIGN_UP_PATH )
227241 .build ();
228242
229243 ParameterizableRequest <DatabaseUser > request = factory .POST (url , client , mapper , DatabaseUser .class );
@@ -284,8 +298,8 @@ public SignUpRequest signUp(String email, String password) {
284298 */
285299 public ChangePasswordRequest changePassword (String email ) {
286300 HttpUrl url = HttpUrl .parse (auth0 .getDomainUrl ()).newBuilder ()
287- .addPathSegment ("dbconnections" )
288- .addPathSegment ("change_password" )
301+ .addPathSegment (DB_CONNECTIONS_PATH )
302+ .addPathSegment (CHANGE_PASSWORD_PATH )
289303 .build ();
290304
291305 ParameterizableRequest <Void > request = factory .POST (url , client , mapper );
@@ -365,14 +379,14 @@ public DelegationRequest<Map<String, Object>> delegationWithRefreshToken(String
365379 public Request <Void > unlink (String userId , String accessToken ) {
366380 //TODO: Test this after removing .set("clientID", getClientId())
367381 HttpUrl url = HttpUrl .parse (auth0 .getDomainUrl ()).newBuilder ()
368- .addPathSegment ("unlink" )
382+ .addPathSegment (UNLINK_PATH )
369383 .build ();
370384
371385 ParameterizableRequest <Void > request = factory .POST (url , client , mapper );
372386 request .getParameterBuilder ()
373387 .setClientId (getClientId ())
374388 .setAccessToken (accessToken )
375- .set ("user_id" , userId );
389+ .set (USER_ID_KEY , userId );
376390 return request ;
377391 }
378392
@@ -388,7 +402,7 @@ public ParameterizableRequest<Void> passwordlessWithEmail(String email, Password
388402 request .getParameterBuilder ()
389403 .set (EMAIL_KEY , email )
390404 .setSend (passwordlessType )
391- .setConnection ("email" );
405+ .setConnection (EMAIL_CONNECTION );
392406 return request ;
393407 }
394408
@@ -404,7 +418,7 @@ public ParameterizableRequest<Void> passwordlessWithSMS(String phoneNumber, Pass
404418 request .getParameterBuilder ()
405419 .set (PHONE_NUMBER_KEY , phoneNumber )
406420 .setSend (passwordlessType )
407- .setConnection ("sms" );
421+ .setConnection (SMS_CONNECTION );
408422 return request ;
409423 }
410424
@@ -416,7 +430,7 @@ public ParameterizableRequest<Void> passwordlessWithSMS(String phoneNumber, Pass
416430 */
417431 public ParameterizableRequest <Map <String , Object >> delegation () {
418432 HttpUrl url = HttpUrl .parse (auth0 .getDomainUrl ()).newBuilder ()
419- .addPathSegment ("delegation" )
433+ .addPathSegment (DELEGATION_PATH )
420434 .build ();
421435
422436 ParameterizableRequest <Map <String , Object >> request = factory .rawPOST (url , client , mapper );
@@ -428,7 +442,7 @@ public ParameterizableRequest<Map<String, Object>> delegation() {
428442
429443 protected <T > ParameterizableRequest <T > delegation (Class <T > clazz ) {
430444 HttpUrl url = HttpUrl .parse (auth0 .getDomainUrl ()).newBuilder ()
431- .addPathSegment ("delegation" )
445+ .addPathSegment (DELEGATION_PATH )
432446 .build ();
433447
434448 ParameterizableRequest <T > request = factory .POST (url , client , mapper , clazz );
@@ -446,8 +460,8 @@ protected <T> ParameterizableRequest<T> delegation(Class<T> clazz) {
446460 */
447461 public ParameterizableRequest <Void > passwordless () {
448462 HttpUrl url = HttpUrl .parse (auth0 .getDomainUrl ()).newBuilder ()
449- .addPathSegment ("passwordless" )
450- .addPathSegment ("start" )
463+ .addPathSegment (PASSWORDLESS_PATH )
464+ .addPathSegment (START_PATH )
451465 .build ();
452466
453467 ParameterizableRequest <Void > request = factory .POST (url , client , mapper );
@@ -457,8 +471,8 @@ public ParameterizableRequest<Void> passwordless() {
457471
458472 protected ParameterizableRequest <Token > loginWithResourceOwner () {
459473 HttpUrl url = HttpUrl .parse (auth0 .getDomainUrl ()).newBuilder ()
460- .addPathSegment ("oauth" )
461- .addPathSegment ("ro" )
474+ .addPathSegment (OAUTH_PATH )
475+ .addPathSegment (RESOURCE_OWNER_PATH )
462476 .build ();
463477
464478 ParameterizableRequest <Token > request = factory .POST (url , client , mapper , Token .class );
@@ -470,7 +484,7 @@ protected ParameterizableRequest<Token> loginWithResourceOwner() {
470484
471485 private ParameterizableRequest <UserProfile > profileRequest () {
472486 HttpUrl url = HttpUrl .parse (auth0 .getDomainUrl ()).newBuilder ()
473- .addPathSegment ("tokeninfo" )
487+ .addPathSegment (TOKEN_INFO_PATH )
474488 .build ();
475489
476490 return factory .POST (url , client , mapper , UserProfile .class );
0 commit comments