diff --git a/lib/weixin_rails_middleware/engine.rb b/lib/weixin_rails_middleware/engine.rb
index <HASH>..<HASH> 100644
--- a/lib/weixin_rails_middleware/engine.rb
+++ b/lib/weixin_rails_middleware/engine.rb
@@ -1,7 +1,25 @@
 module WeixinRailsMiddleware
   class Engine < ::Rails::Engine
+    include ConfigurationHelpers
+
     isolate_namespace WeixinRailsMiddleware
     engine_name :weixin_engine
 
+    config.after_initialize do
+      token_model_callback if token_model.present?
+    end
+
+    private
+
+      def token_model_callback
+        token_model_class.class_eval do
+          before_create do
+            # TODO: refactor
+            self.weixin_secret_key = WeiXinUniqueToken.generate(generator: :urlsafe_base64, size: 24)
+            self.weixin_token = WeiXinUniqueToken.generate if weixin_token.blank?
+          end
+        end
+      end
+
   end
 end
added token_model_callback after initialize