Example #1
0
        public void StaffTokenTest()
        {
            RestRequestStaffInfo staff = new RestRequestStaffInfo
            {
                Username     = "******",
                Password     = "******",
                Scope        = "urn:mboframeworkapi",
                GrantType    = "password",
                SubscriberId = -4926
            };

            StaffRestCalls staffRestCalls = new StaffRestCalls();

            IRestResponse response = staffRestCalls.StaffToken(staff);

            Console.WriteLine(response.Content);

            Assert.AreNotEqual(0, response.ContentLength);
        }
        public IRestResponse StaffToken(RestRequestStaffInfo staff)
        {
            var client = new RestClient("https://auth.mbodev.me");

            var request = new RestRequest("/issue/oauth2/token", Method.POST)
            {
                RequestFormat = DataFormat.Json
            };

            request.AddHeader("Content-Type", "application/json");
            request.AddHeader("Authorization", "Basic aW50ZWdyYXRpb25fY2xpZW50OnNlY3JldA==");

            request.AddBody(
                new
            {
                username     = staff.Username,
                password     = staff.Password,
                scope        = staff.Scope,
                grant_type   = staff.GrantType,
                subscriberid = staff.SubscriberId
            });

            return(client.Execute(request));
        }