我不知道如何使用adal4j庫獲取沒有用戶名和密碼的令牌。我有這樣的代碼:嘗試使用adal4j獲取令牌
public class GetToken implements AuthenticationCallback {
public static void main(String[] args) {
// TODO Auto-generated method stub
String resource = "resource";
String redirectUrl = "redirecturl";
String authority = "https://login.microsoftonline.com/common/";
ExecutorService executor = null;
ClientAssertion clientId = new ClientAssertion("my-client-id");
AuthenticationCallback callback;
// Authenticate the registered application with Azure Active Directory.
AuthenticationContext authContext;
try {
authContext = new AuthenticationContext(authority, false,executor);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Future <AuthenticationResult> result = authContext.acquireToken(resource, clientId, callback);
}
@Override
public void onSuccess(AuthenticationResult result) {
// TODO Auto-generated method stub
}
@Override
public void onFailure(Throwable exc) {
// TODO Auto-generated method stub
}
}
而且我不知道如何獲得令牌....
請描述你正在收到的錯誤,還有什麼已經嘗試 –