@@ -27,6 +27,9 @@ public class GraphServiceClientManager extends Application implements IAuthentic
2727 private static GraphServiceClientManager INSTANCE ;
2828 private AuthenticationManager mAuthenticationManager ;
2929 private static Activity connectActivity ;
30+ private MSALAuthenticationProvider msalAuthenticationProvider ;
31+ private IGraphServiceClient graphClient ;
32+
3033
3134 public static GraphServiceClientManager getApp () {
3235 return INSTANCE ;
@@ -77,17 +80,20 @@ public synchronized IGraphServiceClient getGraphServiceClient() {
7780
7881 public synchronized IGraphServiceClient getGraphServiceClient (IAuthenticationProvider authenticationProvider ) {
7982 if (mGraphServiceClient == null ) {
80- MSALAuthenticationProvider msalAuthenticationProvider = new MSALAuthenticationProvider (
81- getAppActivity (),
82- GraphServiceClientManager .getApp (),
83- mAuthenticationManager .getPublicClient (),
84- Constants .SCOPES );
85-
86- IGraphServiceClient graphClient =
87- GraphServiceClient
88- .builder ()
89- .authenticationProvider (msalAuthenticationProvider )
90- .buildClient ();
83+ if (msalAuthenticationProvider == null ){
84+ msalAuthenticationProvider = new MSALAuthenticationProvider (
85+ getAppActivity (),
86+ GraphServiceClientManager .getApp (),
87+ mAuthenticationManager .getPublicClient (),
88+ Constants .SCOPES );
89+ }
90+ if (graphClient == null ){
91+ graphClient =
92+ GraphServiceClient
93+ .builder ()
94+ .authenticationProvider (msalAuthenticationProvider )
95+ .buildClient ();
96+ }
9197 return graphClient ;
9298 }
9399 return mGraphServiceClient ;
0 commit comments