Added a way to check the creds to see if its is an object or a location and handles it accordingly.

Thanks for breaking the bigger function apart.  Personally, I wouldn't have gone as far as this function (or `setOptions`) since they're barely doing anything and what they're doing is reasonable within the context of the single caller.  (Note that I'm not saying you need to change it :).