@@ -99,6 +99,17 @@ private String createBaseUrl(String domain) {
9999
100100 /**
101101 * Creates a new instance of the {@link AuthorizeUrlBuilder} with the given redirect url.
102+ * i.e.:
103+ * <p>
104+ * <pre>
105+ * AuthAPI auth = new AuthAPI("me.auth0.com", "B3c6RYhk1v9SbIJcRIOwu62gIUGsnze", "2679NfkaBn62e6w5E8zNEzjr-yWfkaBne");
106+ * String url = auth.authorizeUrl("https://me.auth0.com/callback")
107+ * .withConnection("facebook")
108+ * .withAudience("https://api.me.auth0.com/users")
109+ * .withScope("openid contacts")
110+ * .withState("my-custom-state")
111+ * .build();
112+ * </pre>
102113 *
103114 * @param redirectUri the redirect_uri value to set, white-listed in the client settings. Must be already URL Encoded.
104115 * @return a new instance of the {@link AuthorizeUrlBuilder} to configure.
@@ -111,6 +122,14 @@ public AuthorizeUrlBuilder authorizeUrl(String redirectUri) {
111122
112123 /**
113124 * Creates a new instance of the {@link LogoutUrlBuilder} with the given return-to url.
125+ * i.e.:
126+ * <p>
127+ * <pre>
128+ * AuthAPI auth = new AuthAPI("me.auth0.com", "B3c6RYhk1v9SbIJcRIOwu62gIUGsnze", "2679NfkaBn62e6w5E8zNEzjr-yWfkaBne");
129+ * String url = auth.logoutUrl("https://me.auth0.com/home", true)
130+ * .useFederated(true)
131+ * .withAccessToken("A9CvPwFojaBIA9CvI");
132+ * </pre>
114133 *
115134 * @param returnToUrl the redirect_uri value to set, white-listed in the client settings. Must be already URL Encoded.
116135 * @param setClientId whether the client_id value must be set or not. This affects the white-list that the Auth0's Dashboard uses to validate the returnTo url.
@@ -125,6 +144,16 @@ public LogoutUrlBuilder logoutUrl(String returnToUrl, boolean setClientId) {
125144
126145 /**
127146 * Request the user information related to the access token.
147+ * i.e.:
148+ * <p>
149+ * <pre>
150+ * AuthAPI auth = new AuthAPI("me.auth0.com", "B3c6RYhk1v9SbIJcRIOwu62gIUGsnze", "2679NfkaBn62e6w5E8zNEzjr-yWfkaBne");
151+ * try {
152+ * UserInfo result = auth.userInfo("A9CvPwFojaBIA9CvI").execute();
153+ * } catch (Auth0Exception e) {
154+ * //Something happened
155+ * }
156+ * </pre>
128157 *
129158 * @param accessToken a valid access token belonging to an API signed with RS256 algorithm and containing the scope 'openid'.
130159 * @return a Request to execute.
@@ -146,6 +175,16 @@ public Request<UserInfo> userInfo(String accessToken) {
146175 /**
147176 * Request a password reset for the given email and database connection. The response will always be successful even if
148177 * there's no user associated to the given email for that database connection.
178+ * i.e.:
179+ * <p>
180+ * <pre>
181+ * AuthAPI auth = new AuthAPI("me.auth0.com", "B3c6RYhk1v9SbIJcRIOwu62gIUGsnze", "2679NfkaBn62e6w5E8zNEzjr-yWfkaBne");
182+ * try {
183+ * auth.resetPassword("me@auth0.com", "db-connection").execute();
184+ * } catch (Auth0Exception e) {
185+ * //Something happened
186+ * }
187+ * </pre>
149188 *
150189 * @param email the email associated to the database user.
151190 * @param connection the database connection where the user was created.
@@ -171,6 +210,21 @@ public Request resetPassword(String email, String connection) {
171210 /**
172211 * Creates a new sign up request with the given credentials and database connection.
173212 * "Requires Username" option must be turned on in the Connection's configuration first.
213+ * i.e.:
214+ * <p>
215+ * <pre>
216+ * AuthAPI auth = new AuthAPI("me.auth0.com", "B3c6RYhk1v9SbIJcRIOwu62gIUGsnze", "2679NfkaBn62e6w5E8zNEzjr-yWfkaBne");
217+ * try {
218+ * Map<String, String> fields = new HashMap<String, String>();
219+ * fields.put("age", "25);
220+ * fields.put("city", "Buenos Aires");
221+ * auth.signUp("me@auth0.com", "myself", "topsecret", "db-connection")
222+ * .setCustomFields(fields)
223+ * .execute();
224+ * } catch (Auth0Exception e) {
225+ * //Something happened
226+ * }
227+ * </pre>
174228 *
175229 * @param email the desired user's email.
176230 * @param username the desired user's username.
@@ -188,6 +242,21 @@ public SignUpRequest signUp(String email, String username, String password, Stri
188242
189243 /**
190244 * Creates a new sign up request with the given credentials and database connection.
245+ * i.e.:
246+ * <p>
247+ * <pre>
248+ * AuthAPI auth = new AuthAPI("me.auth0.com", "B3c6RYhk1v9SbIJcRIOwu62gIUGsnze", "2679NfkaBn62e6w5E8zNEzjr-yWfkaBne");
249+ * try {
250+ * Map<String, String> fields = new HashMap<String, String>();
251+ * fields.put("age", "25);
252+ * fields.put("city", "Buenos Aires");
253+ * auth.signUp("me@auth0.com", "topsecret", "db-connection")
254+ * .setCustomFields(fields)
255+ * .execute();
256+ * } catch (Auth0Exception e) {
257+ * //Something happened
258+ * }
259+ * </pre>
191260 *
192261 * @param email the desired user's email.
193262 * @param password the desired user's password.
@@ -215,6 +284,18 @@ public SignUpRequest signUp(String email, String password, String connection) {
215284
216285 /**
217286 * Creates a new log in request using the 'Password' grant and the given credentials.
287+ * i.e.:
288+ * <p>
289+ * <pre>
290+ * AuthAPI auth = new AuthAPI("me.auth0.com", "B3c6RYhk1v9SbIJcRIOwu62gIUGsnze", "2679NfkaBn62e6w5E8zNEzjr-yWfkaBne");
291+ * try {
292+ * TokenHolder result = auth.login("me@auth0.com", "topsecret")
293+ * .setScope("openid email nickname")
294+ * .execute();
295+ * } catch (Auth0Exception e) {
296+ * //Something happened
297+ * }
298+ * </pre>
218299 *
219300 * @param emailOrUsername the identity of the user.
220301 * @param password the password of the user.
@@ -233,7 +314,7 @@ public AuthRequest login(String emailOrUsername, String password) {
233314 TokenRequest request = new TokenRequest (client , url );
234315 request .addParameter (KEY_CLIENT_ID , clientId );
235316 request .addParameter (KEY_CLIENT_SECRET , clientSecret );
236- request .addParameter (KEY_GRANT_TYPE , KEY_PASSWORD );
317+ request .addParameter (KEY_GRANT_TYPE , "password" );
237318 request .addParameter (KEY_USERNAME , emailOrUsername );
238319 request .addParameter (KEY_PASSWORD , password );
239320 return request ;
@@ -242,6 +323,17 @@ public AuthRequest login(String emailOrUsername, String password) {
242323 /**
243324 * Creates a new log in request using the 'Password Realm' grant and the given credentials.
244325 * Default used realm and audience are defined in the "API Authorization Settings" in the account's advanced settings in the Auth0 Dashboard.
326+ * <p>
327+ * <pre>
328+ * AuthAPI auth = new AuthAPI("me.auth0.com", "B3c6RYhk1v9SbIJcRIOwu62gIUGsnze", "2679NfkaBn62e6w5E8zNEzjr-yWfkaBne");
329+ * try {
330+ * TokenHolder result = auth.login("me@auth0.com", "topsecret", "my-realm")
331+ * .setAudience("https://myapi.me.auth0.com/users")
332+ * .execute();
333+ * } catch (Auth0Exception e) {
334+ * //Something happened
335+ * }
336+ * </pre>
245337 *
246338 * @param emailOrUsername the identity of the user.
247339 * @param password the password of the user.
@@ -270,7 +362,18 @@ public AuthRequest login(String emailOrUsername, String password, String realm)
270362
271363 /**
272364 * Creates a new request to get a Token for the given audience using the 'Client Credentials' grant.
273- * Default used realm and audience are defined in the "API Authorization Settings" in the account's advanced settings in the Auth0 Dashboard.
365+ * Default used realm is defined in the "API Authorization Settings" in the account's advanced settings in the Auth0 Dashboard.
366+ * <p>
367+ * <pre>
368+ * AuthAPI auth = new AuthAPI("me.auth0.com", "B3c6RYhk1v9SbIJcRIOwu62gIUGsnze", "2679NfkaBn62e6w5E8zNEzjr-yWfkaBne");
369+ * try {
370+ * TokenHolder result = auth.requestToken("https://myapi.me.auth0.com/users")
371+ * .setRealm("my-realm")
372+ * .execute();
373+ * } catch (Auth0Exception e) {
374+ * //Something happened
375+ * }
376+ * </pre>
274377 *
275378 * @param audience the audience of the API to request access to.
276379 * @return a Request to configure and execute.
@@ -294,6 +397,17 @@ public AuthRequest requestToken(String audience) {
294397
295398 /**
296399 * Creates a new request to exchange the code obtained in the /authorize call using the 'Authorization Code' grant.
400+ * <p>
401+ * <pre>
402+ * AuthAPI auth = new AuthAPI("me.auth0.com", "B3c6RYhk1v9SbIJcRIOwu62gIUGsnze", "2679NfkaBn62e6w5E8zNEzjr-yWfkaBne");
403+ * try {
404+ * TokenHolder result = auth.exchangeCode("SnWoFLMzApDskr", "https://me.auth0.com/callback")
405+ * .setScope("openid name nickname")
406+ * .execute();
407+ * } catch (Auth0Exception e) {
408+ * //Something happened
409+ * }
410+ * </pre>
297411 *
298412 * @param code the authorization code received from the /authorize call.
299413 * @param redirectUri the redirect uri sent on the /authorize call.
0 commit comments