Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > API Authentication >

XeroApiPublicSession(string, string, string) is objolete

Started by Paul Liu -   in API Authentication

Hi, the error message is:

"XeroApi.OAuth.XeroApiPublicSession.XeroApiPublicSession(string, string, string)' is obsolete:
'Use the constructor with ITokenRepository'

I got this warring message, please supply an usage example for that.

Hi, I downloaded the new version of XeroApi Code (commit code c2d9) and the code changed a lot, seems the new demo code answered my question.

Paul Liu  

Hi Paul,

Yes, I recently wrote in a bunch of code for automatic storage and retrieval of request and access tokens. The change seemed significant enough to warrant incrementing the minor version number on the library.

The idea of marking the old constructor of XeroApiPublicSession obsolete, was to encourage developers to use a TokenRepository.

Whilst this may seem a little complicated for Public apps, the real benefit of using the TokenRepository pattern comes when you upgrade to partner status. Partner Apps can refresh the access token every 30 minutes. The refreshing of access tokens is now done automatically within the XeroAPI.Net wrapper library. If you've implemented a ITokenRepository class when developing a Public App, upgrading should hopefully be a lot easier.


Dan Barratt (Xero Staff)  

Hi Dan,

Thank you for explain the intention for the new API change.

Paul Liu