Added Support for Refresh Token

* Added support for refresh_token dance.
* Cleaned up code to make it more DRY.