我正在尝试使用 java 实现 msgraph 订阅。我有以下代码。我能够获取访问令牌,但无法使用 graphClient 并且对如何提供 notificationUrl 及其后端处理也有疑问。
尝试{
final ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId(CLIENT_ID)
.clientSecret(CLIENT_SECRET)
.tenantId(TENANT)
.build();
final GraphServiceClient graphClient =
GraphServiceClient
.builder()
.authenticationProvider( Some authprovider here goes here )
.buildClient();
Subscription subscription = new Subscription();
subscription.changeType = "created";
subscription.notificationUrl = "http://localhost:4200/1/mynotification";
subscription.resource = "/users";
subscription.expirationDateTime = OffsetDateTimeSerializer.deserialize("2022-03-20T18:23:45.9356913Z");
subscription.clientState = "secretClientValue";
// subscription.latestSupportedTlsVersion = "v1_2";
Subscription graphresult = graphClient.subscriptions()
.buildRequest()
.post(subscription);
System.out.println("graphresult :"+graphresult );
} catch (Exception e) {
e.printStackTrace();
logger.info("\nException : "+e);
}
我希望有一个人可以帮助我!这将是一个很大的帮助!
谢谢你的时间!