Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Partner Program >

Renew Token in Partner Application Xero Net

Started by Dryrun Team -   in Partner Program

I've looked through so many discussions but can't seem to find an answer. How do I call the renew token function in the api? I'm using the wrapper for the PartnerMvcAuthenticator with my token store pulling the access tokens from an SQL Database - storing the tokens as a serialized string.

Here is the code to test if the token has expired:

public class AccessTokenStore: ITokenStore
public IToken Find(string userId)
var token = _organization?.AccessToken;
if (token == null) return null;

// Determine if token is expired by comparing the current UTC date to expiry date
var iToken = new JavaScriptSerializer().Deserialize<XeroToken>(token);
var isExpired = iToken.ExpiresAt.GetValueOrDefault() < DateTime.UtcNow;

if (isExpired)
// How to renew token from here?

return iToken;

Right now we are just asking users to reconnect when the token has expired which as you can imagine is a extremely cumbersome. Please help!
Hi there,

You're on the right track for removing the need to reconnect every half hour. To use the PartnerMvcAuthenticator, you need to be registered as a developer partner with Xero: https://developer.xero.com/partner/developer-partner - I'm guessing you haven't been through this process yet?

Fill in the form and one of the developer evangelists will be in touch soon - cheers!


Russell Dear (Xero Staff)  

Yes we've already registered as a partner application. My question is about renewing the access token after it has expired.

Dryrun Team  

Ah, ok - cool. There's a RenewToken method on the PartnerMvcAuthenticator - does that do the job?


Russell Dear (Xero Staff)