diff --git a/examples/management-cli/pom.xml b/examples/management-cli/pom.xml index 7f250f41..ca63f8f9 100644 --- a/examples/management-cli/pom.xml +++ b/examples/management-cli/pom.xml @@ -19,7 +19,7 @@ com.descope java-sdk - 1.0.24 + 1.0.25 info.picocli diff --git a/pom.xml b/pom.xml index 9aba249c..92cf6568 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.descope java-sdk 4.0.0 - 1.0.24 + 1.0.25 ${project.groupId}:${project.artifactId} Java library used to integrate with Descope. https://github.com/descope/descope-java diff --git a/src/main/java/com/descope/sdk/auth/TOTPService.java b/src/main/java/com/descope/sdk/auth/TOTPService.java index c7fbbf38..d83ea6ae 100644 --- a/src/main/java/com/descope/sdk/auth/TOTPService.java +++ b/src/main/java/com/descope/sdk/auth/TOTPService.java @@ -62,4 +62,16 @@ AuthenticationInfo signInCode( */ TOTPResponse updateUser(String loginId) throws DescopeException; + + + /** + * Set a seed to an existing user, so the user can use an authenticator app. + * + * @param loginId - User login ID + * @param refreshToken - Refresh Token + * @return TOTPResponse + * @throws DescopeException - error upon failure + */ + TOTPResponse updateUser(String loginId, String refreshToken) + throws DescopeException; } diff --git a/src/main/java/com/descope/sdk/auth/impl/TOTPServiceImpl.java b/src/main/java/com/descope/sdk/auth/impl/TOTPServiceImpl.java index b83df56f..bf94da84 100644 --- a/src/main/java/com/descope/sdk/auth/impl/TOTPServiceImpl.java +++ b/src/main/java/com/descope/sdk/auth/impl/TOTPServiceImpl.java @@ -70,13 +70,23 @@ public AuthenticationInfo signInCode(String loginId, String code, LoginOptions l @Override public TOTPResponse updateUser(String loginId) throws DescopeException { + return updateUser(loginId, null); + } + + @Override + public TOTPResponse updateUser(String loginId, String refreshToken) throws DescopeException { if (StringUtils.isBlank(loginId)) { throw ServerCommonException.invalidArgument("loginId"); } URI totpUpdateUser = composeUpdateTOTPURL(); TotpSignUpRequestBody signUpRequest = TotpSignUpRequestBody.builder().loginId(loginId).build(); - ApiProxy apiProxy = getApiProxy(); + ApiProxy apiProxy; + if (StringUtils.isBlank(refreshToken)) { + apiProxy = getApiProxy(); + } else { + apiProxy = getApiProxy(refreshToken); + } return apiProxy.post(totpUpdateUser, signUpRequest, TOTPResponse.class); }