Refactor token creation, take a proxy and handler argument