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 PublicMvcAuthenticator 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!
Hello,

The PublicMvcAuthenticator is designed for public applications. If you have a partner app you should be using the PartnerMvcAuthenticator instead.

Public apps are not permitted to refresh their tokens. The public app type (and its 30 minute re-authentication) is intended as an intermediate stage on the journey to becoming a partner app. See https://developer.xero.com/documentation/auth-and-limits/partner-applications for more information about partner applications.

Regards,
Amy
 

Amy Martin (Xero Staff)  

Using PartnerMvcAuthenticator, I have updated the question.
 

Dryrun Team  

I've created a new question because there seems to be no way to edit my question!
 

Dryrun Team