Python Rest Api Token Based Algorithm