Skip to content

Commit 9f1bac6

Browse files
committed
Some docs update
1 parent 18aafc6 commit 9f1bac6

2 files changed

Lines changed: 39 additions & 109 deletions

File tree

lib/src/main/java/com/auth0/authentication/AuthenticationAPIClient.java

Lines changed: 38 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -139,20 +139,20 @@ public void setDefaultDbConnection(String defaultDbConnection) {
139139
* Log in a user with email/username and password using a DB connection.
140140
* Example usage:
141141
* <pre><code>
142-
* client.login("username", "password")
142+
* client.login("{username or email}", "{password}")
143143
* .setConnection("second-database")
144144
* .start(new BaseCallback<Credentials>() {
145145
* {@literal@}Override
146146
* public void onSuccess(Credentials payload) { }
147-
* <p/>
147+
*
148148
* {@literal@}Override
149149
* public void onFailure(Auth0Exception error) { }
150150
* });
151151
* </code></pre>
152152
*
153153
* @param usernameOrEmail of the user depending of the type of DB connection
154154
* @param password of the user
155-
* @return a request to configure and start that will yield{@link Credentials}
155+
* @return a request to configure and start that will yield {@link Credentials}
156156
*/
157157
public AuthenticationRequest login(String usernameOrEmail, String password) {
158158
Map<String, Object> requestParameters = ParameterBuilder.newAuthenticationBuilder()
@@ -167,12 +167,12 @@ public AuthenticationRequest login(String usernameOrEmail, String password) {
167167
* Log in a user with a OAuth 'access_token' of a Identity Provider like Facebook or Twitter using <a href="https://auth0.com/docs/auth-api#!#post--oauth-access_token">'\oauth\access_token' endpoint</a>
168168
* Example usage:
169169
* <pre><code>
170-
* client.loginWithOAuthAccessToken("token", "my-connection")
170+
* client.loginWithOAuthAccessToken("{token}", "{connection name}")
171171
* .setConnection("second-database")
172172
* .start(new BaseCallback<Credentials>() {
173173
* {@literal@}Override
174174
* public void onSuccess(Credentials payload) { }
175-
* <p/>
175+
176176
* {@literal@}Override
177177
* public void onFailure(Auth0Exception error) { }
178178
* });
@@ -202,11 +202,11 @@ public AuthenticationRequest loginWithOAuthAccessToken(String token, String conn
202202
* Log in a user using a phone number and a verification code received via SMS (Part of passwordless login flow)
203203
* Example usage:
204204
* <pre><code>
205-
* client.loginWithPhoneNumber("1234567890", "000000")
205+
* client.loginWithPhoneNumber("{phone number}", "{code}")
206206
* .start(new BaseCallback<Credentials>() {
207207
* {@literal@}Override
208208
* public void onSuccess(Credentials payload) { }
209-
* <p/>
209+
210210
* {@literal@}@Override
211211
* public void onFailure(Auth0Exception error) { }
212212
* });
@@ -231,11 +231,11 @@ public AuthenticationRequest loginWithPhoneNumber(String phoneNumber, String ver
231231
* Log in a user using an email and a verification code received via Email (Part of passwordless login flow)
232232
* Example usage:
233233
* <pre><code>
234-
* client.loginWithEmail("email@example.com", "000000")
234+
* client.loginWithEmail("{email}", "{code}")
235235
* .start(new BaseCallback<Credentials>() {
236236
* {@literal@}Override
237237
* public void onSuccess(Credentials payload) { }
238-
* <p/>
238+
239239
* {@literal@}@Override
240240
* public void onFailure(Auth0Exception error) { }
241241
* });
@@ -260,11 +260,11 @@ public AuthenticationRequest loginWithEmail(String email, String verificationCod
260260
* Fetch the token information from Auth0
261261
* Example usage:
262262
* <pre><code>
263-
* client.tokenInfo("idToken")
263+
* client.tokenInfo("{id_token}")
264264
* .start(new BaseCallback<UserProfile>() {
265265
* {@literal@}Override
266266
* public void onSuccess(UserProfile payload) { }
267-
* <p/>
267+
268268
* {@literal@}@Override
269269
* public void onFailure(Auth0Exception error) { }
270270
* });
@@ -282,12 +282,12 @@ public Request<UserProfile> tokenInfo(String idToken) {
282282
* Creates a user in a DB connection using <a href="https://auth0.com/docs/auth-api#!#post--dbconnections-signup">'/dbconnections/signup' endpoint</a>
283283
* Example usage:
284284
* <pre><code>
285-
* client.createUser("email@example.com", "password", "username")
286-
* .setConnection("Username-Password-Authentication")
285+
* client.createUser("{email}", "{password}", "{username}")
286+
* .setConnection("{connection name}")
287287
* .start(new BaseCallback<DatabaseUser>() {
288288
* {@literal@}Override
289289
* public void onSuccess(DatabaseUser payload) { }
290-
* <p/>
290+
*
291291
* {@literal@}@Override
292292
* public void onFailure(Auth0Exception error) { }
293293
* });
@@ -320,12 +320,12 @@ public DatabaseConnectionRequest<DatabaseUser> createUser(String email, String p
320320
* Creates a user in a DB connection using <a href="https://auth0.com/docs/auth-api#!#post--dbconnections-signup">'/dbconnections/signup' endpoint</a>
321321
* Example usage:
322322
* <pre><code>
323-
* client.createUser("email@example.com", "password")
324-
* .setConnection("Username-Password-Authentication")
323+
* client.createUser("{email}", "{password}")
324+
* .setConnection("{connection name}")
325325
* .start(new BaseCallback<DatabaseUser>() {
326326
* {@literal@}Override
327327
* public void onSuccess(DatabaseUser payload) { }
328-
* <p/>
328+
*
329329
* {@literal@}@Override
330330
* public void onFailure(Auth0Exception error) { }
331331
* });
@@ -344,12 +344,12 @@ public DatabaseConnectionRequest<DatabaseUser> createUser(String email, String p
344344
* and then logs in
345345
* Example usage:
346346
* <pre><code>
347-
* client.signUp("email@example.com", "password", "username")
348-
* .setConnection("Username-Password-Authentication")
347+
* client.signUp("{email}", "{password}", "{username}")
348+
* .setConnection("{connection name}")
349349
* .start(new BaseCallback<Credentials>() {
350350
* {@literal@}Override
351351
* public void onSuccess(Credentials payload) {}
352-
* <p/>
352+
*
353353
* {@literal@}Override
354354
* public void onFailure(Auth0Exception error) {}
355355
* });
@@ -371,12 +371,12 @@ public SignUpRequest signUp(String email, String password, String username) {
371371
* and then logs in
372372
* Example usage:
373373
* <pre><code>
374-
* client.signUp("email@example.com", "password")
375-
* .setConnection("Username-Password-Authentication")
374+
* client.signUp("{email}", "{password}")
375+
* .setConnection("{connection name}")
376376
* .start(new BaseCallback<Credentials>() {
377377
* {@literal@}Override
378378
* public void onSuccess(Credentials payload) {}
379-
* <p/>
379+
*
380380
* {@literal@}Override
381381
* public void onFailure(Auth0Exception error) {}
382382
* });
@@ -396,11 +396,11 @@ public SignUpRequest signUp(String email, String password) {
396396
* Request a change password using <a href="https://auth0.com/docs/auth-api#!#post--dbconnections-change_password">'/dbconnections/change_password'</a>
397397
* Example usage:
398398
* <pre><code>
399-
* client.requestChangePassword("email@example.com")
399+
* client.requestChangePassword("{email}")
400400
* .start(new BaseCallback<Void>() {
401401
* {@literal@}Override
402402
* public void onSuccess(Void payload) {}
403-
* <p/>
403+
*
404404
* {@literal@}Override
405405
* public void onFailure(Auth0Exception error) {}
406406
* });
@@ -429,11 +429,11 @@ public DatabaseConnectionRequest<Void> requestChangePassword(String email) {
429429
* Performs a <a href="https://auth0.com/docs/auth-api#!#post--delegation">delegation</a> request that will yield a new Auth0 'id_token'
430430
* Example usage:
431431
* <pre><code>
432-
* client.delegationWithIdToken("idToken")
432+
* client.delegationWithIdToken("{id token}")
433433
* .start(new BaseCallback<Delegation>() {
434434
* {@literal@}Override
435435
* public void onSuccess(Delegation payload) {}
436-
* <p/>
436+
*
437437
* {@literal@}Override
438438
* public void onFailure(Auth0Exception error) {}
439439
* });
@@ -455,11 +455,11 @@ public DelegationRequest<Delegation> delegationWithIdToken(String idToken) {
455455
* Check our <a href="https://auth0.com/docs/refresh-token">refresh token</a> docs for more information
456456
* Example usage:
457457
* <pre><code>
458-
* client.delegationWithRefreshToken("refreshToken")
458+
* client.delegationWithRefreshToken("{refresh token}")
459459
* .start(new BaseCallback<Delegation>() {
460460
* {@literal@}Override
461461
* public void onSuccess(Delegation payload) {}
462-
* <p/>
462+
*
463463
* {@literal@}Override
464464
* public void onFailure(Auth0Exception error) {}
465465
* });
@@ -480,11 +480,11 @@ public DelegationRequest<Delegation> delegationWithRefreshToken(String refreshTo
480480
* Performs a <a href="https://auth0.com/docs/auth-api#!#post--delegation">delegation</a> request that will yield a delegation token.
481481
* Example usage:
482482
* <pre><code>
483-
* client.delegationWithIdToken("idToken", "firebase")
483+
* client.delegationWithIdToken("{id token}", "{app type, e.g. firebase}")
484484
* .start(new BaseCallback<Map<String, Object>>() {
485485
* {@literal@}Override
486486
* public void onSuccess(Map<String, Object> payload) {}
487-
* <p/>
487+
*
488488
* {@literal@}Override
489489
* public void onFailure(Auth0Exception error) {}
490490
* });
@@ -502,41 +502,15 @@ public DelegationRequest<Map<String, Object>> delegationWithIdToken(String idTok
502502
.setApiType(apiType);
503503
}
504504

505-
/**
506-
* Performs a <a href="https://auth0.com/docs/auth-api#!#post--delegation">delegation</a> request that will yield a delegation token.
507-
* Check our <a href="https://auth0.com/docs/refresh-token">refresh token</a> docs for more information
508-
* Example usage:
509-
* <pre><code>
510-
* client.delegationWithRefreshToken("idToken", "firebase")
511-
* .start(new BaseCallback<Map<String, Object>>() {
512-
* {@literal@}Override
513-
* public void onSuccess(Map<String, Object> payload) {}
514-
* <p/>
515-
* {@literal@}Override
516-
* public void onFailure(Auth0Exception error) {}
517-
* });
518-
* </code></pre>
519-
*
520-
* @param refreshToken issued by Auth0 for the user when using the 'offline_access' scope when logging in.
521-
* @param apiType the delegation 'api_type' parameter
522-
* @return a request to configure and start
523-
*/
524-
public DelegationRequest<Map<String, Object>> delegationWithRefreshToken(String refreshToken, String apiType) {
525-
ParameterizableRequest<Map<String, Object>> request = delegation()
526-
.addParameter(ParameterBuilder.REFRESH_TOKEN_KEY, refreshToken);
527-
528-
return new DelegationRequest<>(request).setApiType(apiType);
529-
}
530-
531505
/**
532506
* Unlink a user identity calling <a href="https://auth0.com/docs/auth-api#!#post--unlink">'/unlink'</a> endpoint
533507
* Example usage:
534508
* <pre><code>
535-
* client.unlink("auth0|userId", "accessToken")
509+
* client.unlink("{auth0 user id}", "{user access token}")
536510
* .start(new BaseCallback<Void>() {
537511
* {@literal@}Override
538512
* public void onSuccess(Void payload) {}
539-
* <p/>
513+
*
540514
* {@literal@}Override
541515
* public void onFailure(Auth0Exception error) {}
542516
* });
@@ -565,11 +539,11 @@ public Request<Void> unlink(String userId, String accessToken) {
565539
* Start a passwordless flow with <a href="https://auth0.com/docs/auth-api#!#post--with_email">Email</a>
566540
* Example usage:
567541
* <pre><code>
568-
* client.passwordlessWithEmail("email@example.com", PasswordlessType.CODE)
542+
* client.passwordlessWithEmail("{email}", PasswordlessType.CODE)
569543
* .start(new BaseCallback<Void>() {
570544
* {@literal@}Override
571545
* public void onSuccess(Void payload) {}
572-
* <p/>
546+
*
573547
* {@literal@}Override
574548
* public void onFailure(Auth0Exception error) {}
575549
* });
@@ -594,11 +568,11 @@ public ParameterizableRequest<Void> passwordlessWithEmail(String email, Password
594568
* Start a passwordless flow with <a href="https://auth0.com/docs/auth-api#!#post--with_sms">SMS</a>
595569
* Example usage:
596570
* <pre><code>
597-
* client.passwordlessWithSms("1234567890", PasswordlessType.CODE)
571+
* client.passwordlessWithSms("{phone number}", PasswordlessType.CODE)
598572
* .start(new BaseCallback<Void>() {
599573
* {@literal@}Override
600574
* public void onSuccess(Void payload) {}
601-
* <p/>
575+
*
602576
* {@literal@}Override
603577
* public void onFailure(Auth0Exception error) {}
604578
* });
@@ -628,7 +602,7 @@ public ParameterizableRequest<Void> passwordlessWithSMS(String phoneNumber, Pass
628602
* .start(new BaseCallback<Map<String, Object>>() {
629603
* {@literal@}Override
630604
* public void onSuccess(Map<String, Object> payload) {}
631-
* <p/>
605+
*
632606
* {@literal@}Override
633607
* public void onFailure(Auth0Exception error) {}
634608
* });

lib/src/test/java/com/auth0/authentication/AuthenticationAPIClientTest.java

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -868,51 +868,7 @@ public void shouldGetNewIdTokenWithRefreshTokenSync() throws Exception {
868868

869869
assertThat(delegation, is(notNullValue()));
870870
}
871-
872-
@Test
873-
public void shouldGetCustomizedDelegationRequestWithRefreshToken() throws Exception {
874-
mockAPI.willReturnNewIdToken();
875-
876-
final MockBaseCallback<Map<String, Object>> callback = new MockBaseCallback<>();
877-
client.delegationWithRefreshToken(REFRESH_TOKEN, "custom_api_type")
878-
.setScope("custom_scope")
879-
.setTarget("custom_target")
880-
.start(callback);
881-
882-
final RecordedRequest request = mockAPI.takeRequest();
883-
assertThat(request.getPath(), equalTo("/delegation"));
884-
885-
Map<String, String> body = bodyFromRequest(request);
886-
assertThat(body, hasEntry("grant_type", ParameterBuilder.GRANT_TYPE_JWT));
887-
assertThat(body, hasEntry("client_id", CLIENT_ID));
888-
assertThat(body, hasEntry("api_type", "custom_api_type"));
889-
assertThat(body, hasEntry("scope", "custom_scope"));
890-
assertThat(body, hasEntry("target", "custom_target"));
891-
assertThat(body, hasEntry("refresh_token", REFRESH_TOKEN));
892-
}
893-
894-
@Test
895-
public void shouldGetCustomizedDelegationRequestWithRefreshTokenSync() throws Exception {
896-
mockAPI.willReturnNewIdToken();
897-
898-
client
899-
.delegationWithRefreshToken(REFRESH_TOKEN, "custom_api_type")
900-
.setScope("custom_scope")
901-
.setTarget("custom_target")
902-
.execute();
903-
904-
final RecordedRequest request = mockAPI.takeRequest();
905-
assertThat(request.getPath(), equalTo("/delegation"));
906-
907-
Map<String, String> body = bodyFromRequest(request);
908-
assertThat(body, hasEntry("grant_type", ParameterBuilder.GRANT_TYPE_JWT));
909-
assertThat(body, hasEntry("client_id", CLIENT_ID));
910-
assertThat(body, hasEntry("api_type", "custom_api_type"));
911-
assertThat(body, hasEntry("scope", "custom_scope"));
912-
assertThat(body, hasEntry("target", "custom_target"));
913-
assertThat(body, hasEntry("refresh_token", REFRESH_TOKEN));
914-
}
915-
871+
916872
@Test
917873
public void shouldUnlinkAccount() throws Exception {
918874
mockAPI.willReturnSuccessfulUnlinkAccount();

0 commit comments

Comments
 (0)