token request and some connection management