Exemple #1
0
        //gavdcodeend 04

        //gavdcodebegin 05
        static void CreateChannelApp()
        {
            string graphQuery = "https://graph.microsoft.com/v1.0/teams/" +
                                "5b409eec-a4ae-4f04-a354-0434c444265d/channels";

            string myBody = "{ " +
                            "\"displayName\": \"Graph Channel 01 Application\"," +
                            "\"description\": \"Channel created with Graph\"" +
                            " }";

            RestGraphClient myClient = new RestGraphClient
            {
                ClientID     = ConfigurationManager.AppSettings["ClientIdApp"],
                ClientSecret = ConfigurationManager.AppSettings["ClientSecretApp"],
                TenantName   = ConfigurationManager.AppSettings["TenantName"],
                EndPoint     = graphQuery,
                Method       = HttpVerb.POST,
                ContentType  = "application/json",
                PostData     = myBody,
                Registration = TypeRegistration.Application
            };

            Tuple <string, string> resultText = myClient.SendGraphRequest();

            Console.WriteLine(resultText.Item1);
            Console.WriteLine(resultText.Item2);
        }
Exemple #2
0
        //gavdcodebegin 07
        static void UpdateChannelApp()
        {
            string graphQuery = "https://graph.microsoft.com/v1.0/teams/" +
                                "5b409eec-a4ae-4f04-a354-0434c444265d/channels/" +
                                "19:[email protected]";

            string myBody = "{ \"description\": \"Channel Description Updated\" }";

            List <HeaderConfig> myHeadersList = new List <HeaderConfig>();
            HeaderConfig        myHeaderMat   = new HeaderConfig
            {
                HeaderTitle = "IF-MATCH",
                HeaderValue = "*"
            };

            myHeadersList.Add(myHeaderMat);

            RestGraphClient myClient = new RestGraphClient
            {
                ClientID     = ConfigurationManager.AppSettings["ClientIdApp"],
                ClientSecret = ConfigurationManager.AppSettings["ClientSecretApp"],
                TenantName   = ConfigurationManager.AppSettings["TenantName"],
                EndPoint     = graphQuery,
                Method       = HttpVerb.PATCH,
                ContentType  = "application/json",
                Headers      = myHeadersList,
                PostData     = myBody,
                Registration = TypeRegistration.Application
            };

            Tuple <string, string> resultText = myClient.SendGraphRequest();

            Console.WriteLine(resultText.Item1);
            Console.WriteLine(resultText.Item2);
        }
Exemple #3
0
        public AdAppToken GetAzureTokenDelegation()
        {
            string LoginUrl = "https://login.microsoftonline.com";
            string ScopeUrl = "https://graph.microsoft.com/.default";

            string myUri  = LoginUrl + "/" + TenantName + "/oauth2/v2.0/token";
            string myBody = "Scope=" + HttpUtility.UrlEncode(ScopeUrl) + "&" +
                            "grant_type=Password&" +
                            "client_id=" + ClientID + "&" +
                            "Username="******"&" +
                            "Password="******"";

            RestGraphClient myClient = new RestGraphClient
            {
                EndPoint    = myUri,
                Method      = HttpVerb.POST,
                ContentType = "application/x-www-form-urlencoded",
                PostData    = myBody
            };

            Tuple <string, string> tokenJSON = myClient.SendGraphRequestInternal();

            if (tokenJSON.Item1.Contains("Error") == false)
            {
                AdAppToken tokenObj =
                    JsonConvert.DeserializeObject <AdAppToken>(tokenJSON.Item2);
                return(tokenObj);
            }

            return(null);
        }
Exemple #4
0
        //gavdcodeend 10

        //gavdcodebegin 11
        static AdAppToken GetADTokenApplication()
        {
            RestGraphClient myClient = new RestGraphClient
            {
                ClientID     = ConfigurationManager.AppSettings["ClientIdApp"],
                ClientSecret = ConfigurationManager.AppSettings["ClientSecretApp"],
                TenantName   = ConfigurationManager.AppSettings["TenantName"]
            };

            AdAppToken resultToken = myClient.GetAzureTokenApplication();

            return(resultToken);
        }
Exemple #5
0
        //gavdcodeend 11

        //gavdcodebegin 12
        static AdAppToken GetADTokenDelegation()
        {
            RestGraphClient myClient = new RestGraphClient
            {
                ClientID   = ConfigurationManager.AppSettings["ClientIdDel"],
                TenantName = ConfigurationManager.AppSettings["TenantName"],
                UserName   = ConfigurationManager.AppSettings["UserName"],
                UserPw     = ConfigurationManager.AppSettings["UserPw"]
            };

            AdAppToken resultToken = myClient.GetAzureTokenDelegation();

            return(resultToken);
        }
Exemple #6
0
        //gavdcodebegin 03
        static void GetTeamApp()
        {
            string graphQuery =
                "https://graph.microsoft.com/v1.0/teams/5b409eec-a4ae-4f04-a354-0434c444265d";

            RestGraphClient myClient = new RestGraphClient
            {
                ClientID     = ConfigurationManager.AppSettings["ClientIdApp"],
                ClientSecret = ConfigurationManager.AppSettings["ClientSecretApp"],
                TenantName   = ConfigurationManager.AppSettings["TenantName"],
                EndPoint     = graphQuery,
                Method       = HttpVerb.GET,
                Registration = TypeRegistration.Application
            };

            Tuple <string, string> resultText = myClient.SendGraphRequest();

            Console.WriteLine(resultText.Item1);
            Console.WriteLine(resultText.Item2);
        }
Exemple #7
0
        //gavdcodeend 08

        //gavdcodebegin 09
        static void DeleteChannelApp()
        {
            string graphQuery = "https://graph.microsoft.com/v1.0/teams/" +
                                "5b409eec-a4ae-4f04-a354-0434c444265d/channels/" +
                                "19:[email protected]";

            RestGraphClient myClient = new RestGraphClient
            {
                ClientID     = ConfigurationManager.AppSettings["ClientIdApp"],
                ClientSecret = ConfigurationManager.AppSettings["ClientSecretApp"],
                TenantName   = ConfigurationManager.AppSettings["TenantName"],
                EndPoint     = graphQuery,
                Method       = HttpVerb.DELETE,
                Registration = TypeRegistration.Application
            };

            Tuple <string, string> resultText = myClient.SendGraphRequest();

            Console.WriteLine(resultText.Item1);
            Console.WriteLine(resultText.Item2);
        }
Exemple #8
0
        //gavdcodeend 09

        //gavdcodebegin 10
        static void DeleteChannelDel()
        {
            string graphQuery = "https://graph.microsoft.com/v1.0/teams/" +
                                "5b409eec-a4ae-4f04-a354-0434c444265d/channels/" +
                                "19:[email protected]";

            RestGraphClient myClient = new RestGraphClient
            {
                ClientID     = ConfigurationManager.AppSettings["ClientIdDel"],
                TenantName   = ConfigurationManager.AppSettings["TenantName"],
                UserName     = ConfigurationManager.AppSettings["UserName"],
                UserPw       = ConfigurationManager.AppSettings["UserPw"],
                EndPoint     = graphQuery,
                Method       = HttpVerb.DELETE,
                Registration = TypeRegistration.Delegation
            };

            Tuple <string, string> resultText = myClient.SendGraphRequest();

            Console.WriteLine(resultText.Item1);
            Console.WriteLine(resultText.Item2);
        }