split generate_token_url in two methods