@@ -73,6 +73,7 @@ public class AuthenticationAPIClient {
7373 private static final String TOKEN_INFO_PATH = "tokeninfo" ;
7474 private static final String OAUTH_CODE_KEY = "code" ;
7575 private static final String OAUTH_CODE_VERIFIER_KEY = "code_verifier" ;
76+ private static final String OAUTH_CLIENT_SECRET_KEY = "client_secret" ;
7677 private static final String REDIRECT_URI_KEY = "redirect_uri" ;
7778
7879 private final Auth0 auth0 ;
@@ -703,6 +704,19 @@ private ParameterizableRequest<UserProfile> profileRequest() {
703704 return factory .POST (url , client , gson , UserProfile .class );
704705 }
705706
707+ /**
708+ * For backwards compatibility only
709+ *
710+ * @param authorizationCode
711+ * @param codeVerifier
712+ * @param redirectUri
713+ * @return
714+ */
715+ @ Deprecated
716+ public AuthenticationRequest token (String authorizationCode , String codeVerifier , String redirectUri ) {
717+ return tokenUsingCodeVerifier (authorizationCode , codeVerifier , redirectUri );
718+ }
719+
706720 /**
707721 * Fetch the token information from Auth0, using the authorization_code grant type
708722 *
@@ -711,7 +725,7 @@ private ParameterizableRequest<UserProfile> profileRequest() {
711725 * @param redirectUri the uri to redirect after a successful request.
712726 * @return a request to configure and start
713727 */
714- public AuthenticationRequest token (String authorizationCode , String codeVerifier , String redirectUri ) {
728+ public AuthenticationRequest tokenUsingCodeVerifier (String authorizationCode , String codeVerifier , String redirectUri ) {
715729 Map <String , Object > parameters = ParameterBuilder .newBuilder ()
716730 .setClientId (getClientId ())
717731 .setGrantType (GRANT_TYPE_AUTHORIZATION_CODE )
@@ -728,4 +742,30 @@ public AuthenticationRequest token(String authorizationCode, String codeVerifier
728742 return factory .authenticationPOST (url , client , gson )
729743 .addAuthenticationParameters (parameters );
730744 }
745+
746+ /**
747+ * Fetch the token information from Auth0, using the authorization_code grant type
748+ *
749+ * @param authorizationCode the authorization code received from the /authorize call.
750+ * @param clientSecret the client secret used when requesting a code to /authorize.
751+ * @param redirectUri the uri to redirect after a successful request.
752+ * @return a request to configure and start
753+ */
754+ public AuthenticationRequest tokenUsingClientSecret (final String authorizationCode , final String clientSecret , final String redirectUri ) {
755+ final Map <String , Object > parameters = ParameterBuilder .newBuilder ()
756+ .setClientId (getClientId ())
757+ .setGrantType (GRANT_TYPE_AUTHORIZATION_CODE )
758+ .set (OAUTH_CODE_KEY , authorizationCode )
759+ .set (OAUTH_CLIENT_SECRET_KEY , clientSecret )
760+ .set (REDIRECT_URI_KEY , redirectUri )
761+ .asDictionary ();
762+
763+ final HttpUrl url = HttpUrl .parse (auth0 .getDomainUrl ()).newBuilder ()
764+ .addPathSegment (OAUTH_PATH )
765+ .addPathSegment (TOKEN_PATH )
766+ .build ();
767+
768+ return factory .authenticationPOST (url , client , gson )
769+ .addAuthenticationParameters (parameters );
770+ }
731771}
0 commit comments