Closed schmorrison closed 5 years ago
Added a token persistence method via a GOB encoded datafile. Also a ‘TokenManager’ interface that can be used to provide your own token persistence.
I also wrote a set of methods that satisfy the ‘TokenManager’ interface for usage with AppEngine data store. Again, untested but should provide a jumping off point.
The client libraries released by Zoho provide a persistence mechanism that is backed by MySQL, which adds considerable over head to simply using the client libraries as intended. However the API oAuth2 flow prevents generating too many Access/Refresh tokens. I believe the max is 20 RefreshTokens that can be active at any time, I believe that tokens that are expired are removed from the pool.
In this case I want to add a token persistence mechanism that manages the tokens, and allows the Zoho struct to access the persisted tokens on startup, assuming they haven't expired.
I have started to write some get/set methods backed by BoltDB. However, it may be easier to manage with a simple file. In anycase, there are situations where the system doesn't have disk persistence, a notable example is AppEngine where the primary form a persistence and resource sharing between app instances is Datastore. To this end I believe an interface should be provided that can be implemented in a users package, which gets/sets the access tokens according to their use case persistence scheme.
Once the interface is finalized, users should provide pull requests that perform persistence methods.