2828import com .auth0 .authentication .result .Credentials ;
2929import com .auth0 .authentication .result .DatabaseUser ;
3030import com .auth0 .authentication .result .Delegation ;
31- import com .auth0 .authentication .result .JsonRequiredTypeAdapterFactory ;
3231import com .auth0 .authentication .result .UserProfile ;
3332import com .auth0 .request .AuthenticationRequest ;
3433import com .auth0 .request .ParameterizableRequest ;
3534import com .auth0 .request .Request ;
3635import com .auth0 .request .internal .RequestFactory ;
3736import com .auth0 .util .Telemetry ;
3837import com .google .gson .Gson ;
39- import com .google .gson .GsonBuilder ;
4038import com .squareup .okhttp .HttpUrl ;
4139import com .squareup .okhttp .OkHttpClient ;
4240
@@ -90,7 +88,7 @@ public class AuthenticationAPIClient {
9088 * @param auth0 account information
9189 */
9290 public AuthenticationAPIClient (Auth0 auth0 ) {
93- this (auth0 , new OkHttpClient (), buildGson ());
91+ this (auth0 , new OkHttpClient (), GsonProvider . buildGson ());
9492 }
9593
9694 private AuthenticationAPIClient (Auth0 auth0 , OkHttpClient client , Gson gson ) {
@@ -117,6 +115,7 @@ public String getBaseURL() {
117115 *
118116 * @param userAgent value to send in every request to Auth0
119117 */
118+ @ SuppressWarnings ("unused" )
120119 public void setUserAgent (String userAgent ) {
121120 factory .setUserAgent (userAgent );
122121 }
@@ -126,6 +125,7 @@ public void setUserAgent(String userAgent) {
126125 *
127126 * @param defaultDatabaseConnection name to use on every login with DB connection
128127 */
128+ @ SuppressWarnings ("unused" )
129129 public void setDefaultDatabaseConnection (String defaultDatabaseConnection ) {
130130 this .defaultDatabaseConnection = defaultDatabaseConnection ;
131131 }
@@ -149,6 +149,7 @@ public void setDefaultDatabaseConnection(String defaultDatabaseConnection) {
149149 * @param password of the user
150150 * @return a request to configure and start that will yield {@link Credentials}
151151 */
152+ @ SuppressWarnings ("WeakerAccess" )
152153 public AuthenticationRequest login (String usernameOrEmail , String password ) {
153154 Map <String , Object > requestParameters = ParameterBuilder .newAuthenticationBuilder ()
154155 .set (USERNAME_KEY , usernameOrEmail )
@@ -177,6 +178,7 @@ public AuthenticationRequest login(String usernameOrEmail, String password) {
177178 * @param connection that will be used to authenticate the user, e.g. 'facebook'
178179 * @return a request to configure and start that will yield {@link Credentials}
179180 */
181+ @ SuppressWarnings ("WeakerAccess" )
180182 public AuthenticationRequest loginWithOAuthAccessToken (String token , String connection ) {
181183 HttpUrl url = HttpUrl .parse (auth0 .getDomainUrl ()).newBuilder ()
182184 .addPathSegment (OAUTH_PATH )
@@ -211,6 +213,7 @@ public AuthenticationRequest loginWithOAuthAccessToken(String token, String conn
211213 * @param verificationCode sent by Auth0 via SMS
212214 * @return a request to configure and start that will yield {@link Credentials}
213215 */
216+ @ SuppressWarnings ("WeakerAccess" )
214217 public AuthenticationRequest loginWithPhoneNumber (String phoneNumber , String verificationCode ) {
215218 Map <String , Object > parameters = ParameterBuilder .newAuthenticationBuilder ()
216219 .set (USERNAME_KEY , phoneNumber )
@@ -240,6 +243,7 @@ public AuthenticationRequest loginWithPhoneNumber(String phoneNumber, String ver
240243 * @param verificationCode sent by Auth0 via Email
241244 * @return a request to configure and start that will yield {@link Credentials}
242245 */
246+ @ SuppressWarnings ("WeakerAccess" )
243247 public AuthenticationRequest loginWithEmail (String email , String verificationCode ) {
244248 Map <String , Object > parameters = ParameterBuilder .newAuthenticationBuilder ()
245249 .set (USERNAME_KEY , email )
@@ -268,6 +272,7 @@ public AuthenticationRequest loginWithEmail(String email, String verificationCod
268272 * @param idToken used to fetch it's information
269273 * @return a request to start
270274 */
275+ @ SuppressWarnings ("WeakerAccess" )
271276 public Request <UserProfile > tokenInfo (String idToken ) {
272277 return profileRequest ()
273278 .addParameter (ParameterBuilder .ID_TOKEN_KEY , idToken );
@@ -293,6 +298,7 @@ public Request<UserProfile> tokenInfo(String idToken) {
293298 * @param username of the user and must be non null
294299 * @return a request to start
295300 */
301+ @ SuppressWarnings ("WeakerAccess" )
296302 public DatabaseConnectionRequest <DatabaseUser > createUser (String email , String password , String username ) {
297303 HttpUrl url = HttpUrl .parse (auth0 .getDomainUrl ()).newBuilder ()
298304 .addPathSegment (DB_CONNECTIONS_PATH )
@@ -330,6 +336,7 @@ public DatabaseConnectionRequest<DatabaseUser> createUser(String email, String p
330336 * @param password of the user and must be non null
331337 * @return a request to start
332338 */
339+ @ SuppressWarnings ("WeakerAccess" )
333340 public DatabaseConnectionRequest <DatabaseUser > createUser (String email , String password ) {
334341 return createUser (email , password , null );
335342 }
@@ -355,6 +362,7 @@ public DatabaseConnectionRequest<DatabaseUser> createUser(String email, String p
355362 * @param username of the user and must be non null
356363 * @return a request to configure and start that will yield {@link Credentials}
357364 */
365+ @ SuppressWarnings ("WeakerAccess" )
358366 public SignUpRequest signUp (String email , String password , String username ) {
359367 final DatabaseConnectionRequest <DatabaseUser > createUserRequest = createUser (email , password , username );
360368 final AuthenticationRequest authenticationRequest = login (email , password );
@@ -381,6 +389,7 @@ public SignUpRequest signUp(String email, String password, String username) {
381389 * @param password of the user and must be non null
382390 * @return a request to configure and start that will yield {@link Credentials}
383391 */
392+ @ SuppressWarnings ("WeakerAccess" )
384393 public SignUpRequest signUp (String email , String password ) {
385394 DatabaseConnectionRequest <DatabaseUser > createUserRequest = createUser (email , password );
386395 final AuthenticationRequest authenticationRequest = login (email , password );
@@ -404,6 +413,7 @@ public SignUpRequest signUp(String email, String password) {
404413 * @param email of the user that changes the password. It's also where the email will be sent with the link to perform the change password.
405414 * @return a request to configure and start
406415 */
416+ @ SuppressWarnings ("WeakerAccess" )
407417 public DatabaseConnectionRequest <Void > requestChangePassword (String email ) {
408418 HttpUrl url = HttpUrl .parse (auth0 .getDomainUrl ()).newBuilder ()
409419 .addPathSegment (DB_CONNECTIONS_PATH )
@@ -437,6 +447,7 @@ public DatabaseConnectionRequest<Void> requestChangePassword(String email) {
437447 * @param idToken issued by Auth0 for the user. The token must not be expired.
438448 * @return a request to configure and start
439449 */
450+ @ SuppressWarnings ("WeakerAccess" )
440451 public DelegationRequest <Delegation > delegationWithIdToken (String idToken ) {
441452 ParameterizableRequest <Delegation > request = delegation (Delegation .class )
442453 .addParameter (ParameterBuilder .ID_TOKEN_KEY , idToken );
@@ -463,6 +474,7 @@ public DelegationRequest<Delegation> delegationWithIdToken(String idToken) {
463474 * @param refreshToken issued by Auth0 for the user when using the 'offline_access' scope when logging in.
464475 * @return a request to configure and start
465476 */
477+ @ SuppressWarnings ("WeakerAccess" )
466478 public DelegationRequest <Delegation > delegationWithRefreshToken (String refreshToken ) {
467479 ParameterizableRequest <Delegation > request = delegation (Delegation .class )
468480 .addParameter (ParameterBuilder .REFRESH_TOKEN_KEY , refreshToken );
@@ -489,6 +501,7 @@ public DelegationRequest<Delegation> delegationWithRefreshToken(String refreshTo
489501 * @param apiType the delegation 'api_type' parameter
490502 * @return a request to configure and start
491503 */
504+ @ SuppressWarnings ("WeakerAccess" )
492505 public DelegationRequest <Map <String , Object >> delegationWithIdToken (String idToken , String apiType ) {
493506 ParameterizableRequest <Map <String , Object >> request = delegation ()
494507 .addParameter (ParameterBuilder .ID_TOKEN_KEY , idToken );
@@ -515,6 +528,7 @@ public DelegationRequest<Map<String, Object>> delegationWithIdToken(String idTok
515528 * @param accessToken of the main identity obtained after login
516529 * @return a request to start
517530 */
531+ @ SuppressWarnings ("WeakerAccess" )
518532 public Request <Void > unlink (String userId , String accessToken ) {
519533 HttpUrl url = HttpUrl .parse (auth0 .getDomainUrl ()).newBuilder ()
520534 .addPathSegment (UNLINK_PATH )
@@ -548,6 +562,7 @@ public Request<Void> unlink(String userId, String accessToken) {
548562 * @param passwordlessType indicate whether the email should contain a code, link or magic link (android & iOS)
549563 * @return a request to configure and start
550564 */
565+ @ SuppressWarnings ("WeakerAccess" )
551566 public ParameterizableRequest <Void > passwordlessWithEmail (String email , PasswordlessType passwordlessType ) {
552567 final Map <String , Object > parameters = ParameterBuilder .newBuilder ()
553568 .set (EMAIL_KEY , email )
@@ -577,6 +592,7 @@ public ParameterizableRequest<Void> passwordlessWithEmail(String email, Password
577592 * @param passwordlessType indicate whether the SMS should contain a code, link or magic link (android & iOS)
578593 * @return a request to configure and start
579594 */
595+ @ SuppressWarnings ("WeakerAccess" )
580596 public ParameterizableRequest <Void > passwordlessWithSMS (String phoneNumber , PasswordlessType passwordlessType ) {
581597 final Map <String , Object > parameters = ParameterBuilder .newBuilder ()
582598 .set (PHONE_NUMBER_KEY , phoneNumber )
@@ -605,6 +621,7 @@ public ParameterizableRequest<Void> passwordlessWithSMS(String phoneNumber, Pass
605621 *
606622 * @return a request to configure and start
607623 */
624+ @ SuppressWarnings ("WeakerAccess" )
608625 public ParameterizableRequest <Map <String , Object >> delegation () {
609626 HttpUrl url = HttpUrl .parse (auth0 .getDomainUrl ()).newBuilder ()
610627 .addPathSegment (DELEGATION_PATH )
@@ -618,7 +635,7 @@ public ParameterizableRequest<Map<String, Object>> delegation() {
618635 .addParameters (parameters );
619636 }
620637
621- protected <T > ParameterizableRequest <T > delegation (Class <T > clazz ) {
638+ private <T > ParameterizableRequest <T > delegation (Class <T > clazz ) {
622639 HttpUrl url = HttpUrl .parse (auth0 .getDomainUrl ()).newBuilder ()
623640 .addPathSegment (DELEGATION_PATH )
624641 .build ();
@@ -637,6 +654,7 @@ protected <T> ParameterizableRequest<T> delegation(Class<T> clazz) {
637654 *
638655 * @return a request to configure and start
639656 */
657+ @ SuppressWarnings ("WeakerAccess" )
640658 public ParameterizableRequest <Void > passwordless () {
641659 HttpUrl url = HttpUrl .parse (auth0 .getDomainUrl ()).newBuilder ()
642660 .addPathSegment (PASSWORDLESS_PATH )
@@ -710,10 +728,4 @@ public AuthenticationRequest token(String authorizationCode, String codeVerifier
710728 return factory .authenticationPOST (url , client , gson )
711729 .addAuthenticationParameters (parameters );
712730 }
713-
714- static Gson buildGson () {
715- return new GsonBuilder ()
716- .registerTypeAdapterFactory (new JsonRequiredTypeAdapterFactory ())
717- .create ();
718- }
719731}
0 commit comments