I had issues implementing the API version of this. I believe it had to do with setting the standard scale, the height, and the width of the viewport and the order in which you set them. To make it easy on myself i just went ahead and created a quick method to return the scale factor that I was expecting.
I probably would not have had to do this if there was halfway decent documentation on the API.