We present a deterministic polynomial-time algorithm that decides whether a power product PI(i=1)k gamma(i)n(i) is a unit in the ring integers of K, where K is a number field, gamma(i) are nonzero elements of K and n(i) are rational integers. The main algorithm is based on the factor refinement method for ideals, which might be of independent interest.