我们正在开发一个使用 Microsoft Graph SDK 来实现 Excel/OneDrive 相关功能的项目。我们有一个用例,我们需要序列化和反序列化 IGraphServiceClient
客户引用/对象。
我们试图反序列化该对象,但我们收到了一个 NotSerializableException
异常。我们正在探索 SDK 并找到 ISerializer.java
类,但无法在序列化/反序列化中使用它。
能否请您帮助我们解决这个问题?
UsernamePasswordProvider authProvider =
new UsernamePasswordProvider(clientId, scopes, userName, password, null, tenantid, clientSecret);
IGraphServiceClient client= GraphServiceClient
.builder()
.authenticationProvider((IAuthenticationProvider) authProvider).buildClient());
最佳答案
这是不可能的,坦率地说,序列化/反序列化客户端本身没有任何值(value)。
您真正想要的是请求offline_access
范围,这样您将在 的同时收到一个
用于调用 Microsoft Graph。然后您可以存储 refresh_token
>access_tokenrefresh_token
字符串并使用它来接收更新/新鲜的 access_token
。然后,您可以在需要调用 Microsoft Graph 时使用该 token 创建一个新的 IGraphServiceClient
实例。
关于java - 如何序列化和反序列化 IGraphServiceClient 客户端对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57169069/