예제 #1
0
        //
        // GET: /Drive

        public ActionResult Index(string state, string code)
        {
            try
            {
                IAuthenticator authenticator = Utils.GetCredentials(code, state);
                // Store the authenticator and the authorized service in session
                Session["authenticator"] = authenticator;
                Session["service"] = Utils.BuildService(authenticator);
            }
            catch (CodeExchangeException)
            {
                if (Session["service"] == null || Session["authenticator"] == null)
                {
                    Response.Redirect(Utils.GetAuthorizationUrl("", state));
                }
            }
            catch (NoRefreshTokenException e)
            {
                Response.Redirect(e.AuthorizationUrl);
            }

            DriveState driveState = new DriveState();

            if (!string.IsNullOrEmpty(state))
            {
                JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
                driveState = jsonSerializer.Deserialize<DriveState>(state);
            }

            if (driveState.action == "open")
            {
                return OpenWith(driveState);
            }
            else
            {
                return CreateNew(driveState);
            }
        }
예제 #2
0
 private ActionResult CreateNew(DriveState state)
 {
     ViewBag.FileIds = new string[] {""};
     return View();
 }
예제 #3
0
 private ActionResult OpenWith(DriveState state)
 {
     ViewBag.FileIds = state.ids;
     return View();
 }