2
我試圖通過網絡API中的Java連接的Microsoft Dynamics CRM連接的Microsoft Dynamics CRM試圖通過網絡API中的Java
private final static String AUTHORITY = "XXXXXXXXXXXX";
private final static String CLIENT_ID = "XXXXXXXXXXXX";
private final static String RESOURCE = "XXXXXXXXXXXXXXXXXXX";
public static void main(String args[]) throws Exception {
try (BufferedReader br = new BufferedReader(new InputStreamReader(
System.in))) {
System.out.print("Enter username: ");
String username = br.readLine();
System.out.print("Enter password: ");
String password = br.readLine();
AuthenticationResult result = getAccessTokenFromUserCredentials(
username, password);
System.out.println("Access Token - " + result.getAccessToken());
System.out.println("Refresh Token - " + result.getRefreshToken());
System.out.println("ID Token - " + result.getIdToken());
}
}
private static AuthenticationResult getAccessTokenFromUserCredentials(
String username, String password) throws Exception {
AuthenticationContext context = null;
AuthenticationResult result = null;
ExecutorService service = null;
try {
service = Executors.newFixedThreadPool(1);
context = new AuthenticationContext(AUTHORITY, false, service);
Future<AuthenticationResult> future = context.acquireToken(
RESOURCE, CLIENT_ID, username, password, null);
result = future.get();
} finally {
service.shutdown();
}
if (result == null) {
throw new ServiceUnavailableException(
"authentication result was null");
}
return result;
}
}
我有一個女士動態帳戶,但我不知道如何獲取AUTHORITY,CLIENT_ID和RESOURCE。
我嘗試在https://portal.azure.com那裏創建我的應用程序,我可以看到application_id。是我必須使用的clientid。
任何人都可以請告訴我如何得到這些禮儀。
在此先感謝..