How to serialize and Deserialize IGraphServiceClient client object?

Rais Ali :

We are working on a project which uses Microsoft Graph SDK to implement Excel/OneDrive related functionalities. We have a use-case where we need to serialize and deserialize the IGraphServiceClient client reference/object.

We tried to deserialize the object but we're getting a NotSerializableException exception. We were exploring SDK and find ISerializer.java class but unable to use it in serialization/Deserialization.

Could you please help us how can we get over this issue?

UsernamePasswordProvider authProvider = 
  new UsernamePasswordProvider(clientId, scopes, userName, password, null, tenantid, clientSecret);

IGraphServiceClient client= GraphServiceClient
   .builder()
   .authenticationProvider((IAuthenticationProvider) authProvider).buildClient());
Marc LaFleur :

It isn't possible and, frankly, there is no value in serializing/deserializing the client itself.

What you really want is to request the offline_access scope so that you'll receive a refresh_token at the same time as the access_token your using to call Microsoft Graph. You can then store the refresh_token string and use it to receive an updated/fresh access_token. You can then create a new IGraphServiceClient instance using that token whenever you need to make a call to Microsoft Graph.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=126412&siteId=1