Added support for token authentication (with test).