如何在 Okta Java SDK 中发送短信挑战

How to send sms challenge in Okta Java SDK

如何向使用 Okta Java API 注册因素时给定的 phone 号码发送短信质询?我的代码如下:

    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);