コード例 #1
0
        /// <summary>
        /// Gets the new instance of request parameters.
        /// </summary>
        /// <param name="resource">The resource.</param>
        /// <param name="clientId">The client identifier.</param>
        /// <param name="userCredential">The user credential.</param>
        private static object GetNewInstanceOfRequestParameters(string resource, string clientId, UserCredential userCredential)
        {
            var builder              = new StringBuilder();
            var typeOfParameters     = Type.GetType("Microsoft.IdentityModel.Clients.ActiveDirectory.RequestParameters, Microsoft.IdentityModel.Clients.ActiveDirectory");
            var arguments            = new object[] { builder };
            var instanceOfParameters = (Dictionary <string, string>)Activator.CreateInstance(type: typeOfParameters, args: arguments);

            // Prepare request parameters to be sent over the wire
            instanceOfParameters.Add("grant_type", "password");
            instanceOfParameters.Add("resource", resource);
            instanceOfParameters.Add("username", userCredential.UserName);
            instanceOfParameters.AddSecureParameter("password", userCredential.SecurePassword());
            instanceOfParameters.Add("client_id", clientId);

            return(instanceOfParameters);
        }