[security] add generic token factory.
[doc][security] use generic token factory in doc examples.