コード例 #1
0
        private void Auth_SessionAuthenticated(object sender, SessionAuthenticatedEventArgs e)
        {
            _logger.LogInformation("Don't worry! Access Token was renewed => " + Json(e.Session));
            CookieOptions options = new CookieOptions
            {
                Path     = "/api/Box",
                Expires  = DateTime.Now.AddDays(1),
                HttpOnly = true
            };

            Response.Cookies.Append("boxCred", _protector.Protect(JsonConvert.SerializeObject(e.Session)), options);
        }
コード例 #2
0
        public void SessionAuthenticated(object sender, SessionAuthenticatedEventArgs e)
        {
            // We use a separate connection to ensure that the token gets persisted to the DB, regardless of any transaction rollback.
            // It could potentially happen that the token needs to get refreshed while a file is uploaded, but that this upload ultimately gets rolled back due to another
            // error later during the caller graph persisting process. If we use the current connection scope we have no control over this update.

            using (new PXConnectionScope())
            {
                BoxUserTokens currentUser = PXCache <BoxUserTokens> .CreateCopy(GetCurrentUser());

                currentUser.AccessToken      = e.Session.AccessToken;
                currentUser.RefreshToken     = e.Session.RefreshToken;
                currentUser.RefreshTokenDate = PXTimeZoneInfo.UtcNow;
                Caches[typeof(BoxUserTokens)].Update(currentUser);
                Caches[typeof(BoxUserTokens)].Persist(PXDBOperation.Update);
            }
        }
コード例 #3
0
 /// <summary>
 /// Writes new tokens into tokens.xml file whenever new tokesn are obtained or refreshed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void Auth_SessionAuthenticated(object sender, SessionAuthenticatedEventArgs e)
 {
     TokenConfig.writeTokens(e.Session.AccessToken, e.Session.RefreshToken);
 }