Fix error handling in get_token().