Esempio n. 1
0
        public void Connect()
        {
            if (this.app == null)
            {
                this.app = new GraphApplication(this.GraphUri, this.LoginUri, this.appId);

                var authenticationProvider = new DelegateAuthenticationProvider(
                    (requestMessage) => {
                    var authenticationResult = this.app.GetAccessToken(this.Permissions);

                    requestMessage
                    .Headers
                    .Authorization = new AuthenticationHeaderValue("Bearer", authenticationResult.AccessToken);

                    return(Task.FromResult(0));
                });

                this.graphClient = GraphClientFactory.Create(authenticationProvider, this.ApiVersion, GraphClientFactory.Global_Cloud, null, null);
            }
        }
Esempio n. 2
0
 public void Disconnect()
 {
     this.app         = null;
     this.graphClient = null;
 }