According to @jlee-r7 , he doesn't feel comfortable with returning 0 on success. I suggest returning nil in case of failure.

And calls to get_imperstoken should check returning value against nil.