2016-09-16 80 views
0

我不知道如何使用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 

    } 

} 

而且我不知道如何獲得令牌....

+0

請描述你正在收到的錯誤,還有什麼已經嘗試 –

回答

-1

,你會得到一個IllegalArgumentException傳遞給AuthenticationContext執行人服務爲空。你能分享拋出的異常嗎?

+0

這應該是一個評論,因爲它不回答問題 –

相關問題