Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            // Setup your application here: https://developer.microsoft.com/en-us/graph/docs/concepts/auth_v2_service
            string tenant        = ""; // ex: blrdev.onmicrosoft.com
            string appId         = "";
            string appSecret     = "";
            string graphEndPoint = "https://graph.microsoft.com/beta/";

            // One time process for Admin consent.
            GetOneTimeAdminConsent(tenant, appId);

            string accessToken = GetAccessToken(tenant, appId, appSecret);

            TeamsGraphApiHelper helper = new TeamsGraphApiHelper(graphEndPoint);

            var channelId = "YourChannelId";
            var teamId    = "YourTeamId";

            helper.AddWebsiteTabToChannel(accessToken, teamId, channelId).Wait();

            Console.WriteLine("Added Tab Created successfully");
            Console.ReadLine();

            //helper.CreateNewTeam(new NewTeamDetails()
            //{
            //    TeamName = "Application Context Test 2",
            //    OwnerEmailId = "*****@*****.**",
            //    // ChannelNames = new List<string>() { "Announcements", "Dev Discussion" }, // Currently channel can't be created in App Context.
            //    MemberEmails = new List<string>() { "*****@*****.**", "*****@*****.**", "*****@*****.**" },
            //}, accessToken).Wait();
        }
Ejemplo n.º 2
0
        private static string GetAccessToken(string tenant, string appId, string appSecret)
        {
            string response = TeamsGraphApiHelper.POST($"https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token",
                                                       $"grant_type=client_credentials&client_id={appId}&client_secret={appSecret}"
                                                       + "&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default").Result;

            string accessToken = JsonConvert.DeserializeObject <TeamsGraphApiHelper.TokenResponse>(response).access_token;

            return(accessToken);
        }