在使用Okta Java API进行因素登记时,如何向给定的电话号码发送短信挑战?我的代码如下:
Client client = Clients.builder()
.setOrgUrl(hostname)
.setClientCredentials(new TokenClientCredentials(apikey))
.build();
User user = client.getUser(email);
FactorList factors = user.listFactors();
Factor factor = null;
for (Factor f : factors) {
if (f.getFactorType().toString().equals(authFactor)) {
factor = f;
}
}
if (factor != null && factor.getStatus().toString().equalsIgnoreCase("active")) {
VerifyFactorRequest verifyFactorRequest = client.instantiate(VerifyFactorRequest.class);
// send sms challenge
}
找到了。
VerifyFactorRequest verifyFactorRequest = client.instantiate(VerifyFactorRequest.class);
assert factor != null;
factor.verify(verifyFactorRequest);