예제 #1
0
        public async Task <List <Team> > MyJoinedTeams()
        {
            GraphServiceClient client = await graphTokenService.GetClientForUser(new[] { "profile" });

            IUserJoinedTeamsCollectionPage page = await client.Me.JoinedTeams.Request().GetAsync();

            var data = page.ToList();

            // AddToCache(data, TeamsKey);

            return(data);
        }
예제 #2
0
        public async Task <Microsoft.Graph.User> Me()
        {
            Microsoft.Graph.GraphServiceClient client =
                await graphTokenService.GetClientForUser(new string[] { "profile" });

            Microsoft.Graph.User me = await client.Me.Request().GetAsync();

            return(me);
        }
예제 #3
0
        public async Task <Message> Send(Message mail, string mailboxOrUserId = null, string scope = "profile")
        {
            // use scopes: mail.send, mail.readwrite.shared
            GraphServiceClient client = await tokenService.GetClientForUser(new string[] { scope });

            IUserRequestBuilder userRequestBuilder = string.IsNullOrWhiteSpace(mailboxOrUserId)
                ? client.Me
                : client.Users[mailboxOrUserId];

            Message draft = await userRequestBuilder
                            .MailFolders
                            .Drafts
                            .Messages
                            .Request(new List <HeaderOption>() { new HeaderOption("Prefer", "IdType=\"ImmutableId\"") })
                            .AddAsync(mail);

            await userRequestBuilder.Messages[draft.Id].Send().Request().PostAsync();

            Message msg = await userRequestBuilder.Messages[draft.Id].Request().GetAsync();

            return(msg);
        }