original_docstring: Refresh auth data for a given user
  
          Use refresh token to obtain an new access token.
          Update identity info.
  
          Args:
              user (User): the user to refresh
              handler (tornado.web.RequestHandler or None): the current request handler
          Returns:
              auth_data (bool or dict):
                  Return **True** if auth data for the user is up-to-date
                  and no updates are required.
  
                  Return **False** if the user's auth data has expired,
                  and they should be required to login again.
  
                  Return a **dict** of auth data if some values should be updated.
                  This dict should have the same structure as that returned
                  by :meth:`.authenticate()` when it returns a dict.
                  Any fields present will refresh the value for the user.
                  Any fields not present will be left unchanged.
                  This can include updating `.admin` or `.auth_state` fields.
          
docstring: Refresh auth data for a given user
  Use refresh token to obtain an new access token.
  Update identity info.
docstring_tokens: Refresh auth data for a given user Use refresh token to obtain an new access token . Update identity info .
code: async def refresh_user(self, user, handler=None):
          """Refresh auth data for a given user
  
          Use refresh token to obtain an new access token.
          Update identity info.
  
          Args:
              user (User): the user to refresh
              handler (tornado.web.RequestHandler or None): the current request handler
          Returns:
              auth_data (bool or dict):
                  Return **True** if auth data for the user is up-to-date
                  and no updates are required.
  
                  Return **False** if the user's auth data has expired,
                  and they should be required to login again.
  
                  Return a **dict** of auth data if some values should be updated.
                  This dict should have the same structure as that returned
                  by :meth:`.authenticate()` when it returns a dict.
                  Any fields present will refresh the value for the user.
                  Any fields not present will be left unchanged.
                  This can include updating `.admin` or `.auth_state` fields.
          """
  
          # Nothing to do if we don't have the auth state.
          if not self.enable_auth_state:
              self.log.warn("Failed to refresh access token, enable_auth_state is False")
              return False
  
          auth_state = await user.get_auth_state()
          access_token = auth_state["access_token"]
          refresh_token = auth_state.get("refresh_token")
          refresh_access_token = refresh_token and not self._expired(refresh_token)
          self.log.debug("Checking access token expiry for user %s", user.name)
          if self._expired(access_token):
              self.log.info("Refreshing user info for user %s", user.name)
              if not refresh_access_token:
                  return False
              try:
                  new_auth_state = await self.idp_refresh_token(refresh_token)
              except Exception as e:
                  self.log.warn(
                      "Failed to refresh access token for: %s, exception was %s",
                      user.name,
                      e,
                  )
                  return False
  
              if "refresh_token" in new_auth_state:
                  auth_state["refresh_token"] = new_auth_state["refresh_token"]
              access_token = auth_state["access_token"] = new_auth_state["access_token"]
  
          try:
              userdata = await self.get_idp_userdata(access_token)
          except Exception as e:
              self.log.warn(
                  "Failed to refresh auth info for: %s, exception was %s", user.name, e,
              )
              return False
  
          auth_state["oauth_user"] = userdata
          return {"auth_state": auth_state}
code_tokens: async def refresh_user ( self , user , handler = None ) : if not self . enable_auth_state : self . log . warn ( "Failed to refresh access token, enable_auth_state is False" ) return False auth_state = await user . get_auth_state ( ) access_token = auth_state [ "access_token" ] refresh_token = auth_state . get ( "refresh_token" ) refresh_access_token = refresh_token and not self . _expired ( refresh_token ) self . log . debug ( "Checking access token expiry for user %s" , user . name ) if self . _expired ( access_token ) : self . log . info ( "Refreshing user info for user %s" , user . name ) if not refresh_access_token : return False try : new_auth_state = await self . idp_refresh_token ( refresh_token ) except Exception as e : self . log . warn ( "Failed to refresh access token for: %s, exception was %s" , user . name , e , ) return False if "refresh_token" in new_auth_state : auth_state [ "refresh_token" ] = new_auth_state [ "refresh_token" ] access_token = auth_state [ "access_token" ] = new_auth_state [ "access_token" ] try : userdata = await self . get_idp_userdata ( access_token ) except Exception as e : self . log . warn ( "Failed to refresh auth info for: %s, exception was %s" , user . name , e , ) return False auth_state [ "oauth_user" ] = userdata return { "auth_state" : auth_state }
short_docstring: Refresh auth data for a given user
  Use refresh token to obtain an new access token.
short_docstring_tokens: Refresh auth data for a given user Use refresh token to obtain an new access token .
comment: """Refresh auth data for a given user
  
          Use refresh token to obtain an new access token.
          Update identity info.
  
          Args:
              user (User): the user to refresh
              handler (tornado.web.RequestHandler or None): the current request handler
          Returns:
              auth_data (bool or dict):
                  Return **True** if auth data for the user is up-to-date
                  and no updates are required.
  
                  Return **False** if the user's auth data has expired,
                  and they should be required to login again.
  
                  Return a **dict** of auth data if some values should be updated.
                  This dict should have the same structure as that returned
                  by :meth:`.authenticate()` when it returns a dict.
                  Any fields present will refresh the value for the user.
                  Any fields not present will be left unchanged.
                  This can include updating `.admin` or `.auth_state` fields.
          """$SEP$# Nothing to do if we don't have the auth state.