Example #1
0
        public ActionResult OAuthTest()
        {
            const string username = "******";
            const string password = "******";

            var accessToken = PearsonApiUtilities.GetOauthAccessToken(username, password);

            ViewBag.OAuthResult     = accessToken;
            ViewBag.MeCoursesResult = PearsonApiUtilities.XAuthApiCall(accessToken, "http://m-api.ecollege.com/me/courses");
            ViewBag.CourseDetails   = PearsonApiUtilities.XAuthApiCall(accessToken, "https://m-api.ecollege.com/courses/3312999");
            ViewBag.Students        = PearsonApiUtilities.XAuthApiCall(accessToken, "https://m-api.ecollege.com/courses/3312999/students");
            ViewBag.User            = PearsonApiUtilities.XAuthApiCall(accessToken, "https://m-api.ecollege.com/users/4433390");

            return(View());
        }
Example #2
0
        public ActionResult Test()
        {
            ViewBag.Message = "Api test page.";

            const string username = "******";
            const string password = "******";

            var accessToken = PearsonApiUtilities.GetOauthAccessToken(username, password);

            string[] tokenParts = accessToken.Split('|');

            ViewBag.UserId = tokenParts[2];

            ViewBag.AccessToken = PearsonApiUtilities.EncodeTo64(accessToken);

            return(View());
        }
Example #3
0
        // POST /api/signin
        //[AllowCrossSiteJson]
        public SigninResult Authenticate(string username, string password)
        {
            HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");

            var test  = Request.Content.Headers.ToString();
            var token = PearsonApiUtilities.GetOauthAccessToken(username, password);

            //return token;

            string[] tokenParts = token.Split('|');

            var userID = tokenParts[2];

            var userJson = PearsonApiUtilities.GetUserJson(token, userID);

            var result = new SigninResult()
            {
                EncodedAuthToken = PearsonApiUtilities.EncodeTo64(token),
                UserId           = userID,
                User             = userJson
            };

            return(result);
        }