Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Partner Program >

Token not Valid when Renewing Token - Xero Partner Application

Started by Dryrun Team -   in Partner Program

I'm registered as a partner application in Xero using the .NET SDK for the api. The trouble is that the access token is not being renewed after RenewToken is called. An expired token is read from the database and it then seems to run through the process of renewing the token, but an exception is thrown in this method here:

protected override IToken RenewToken(IToken sessionToken, IConsumer consumer)
var authHeader = GetAuthorization(sessionToken, "POST", Tokens.AccessUri, null, null, true);
// Exception thrown here
var newToken = Tokens.GetAccessToken(sessionToken, authHeader);
return newToken;

The error received is: oauth_problem = token_rejected & oauth_problem_advice = The access token is not valid

We have this up and running but users are being forced to re-authenticate every time as the token renewal never seems to work.
Best Reply as chosen by Dryrun Team (Original Poster)
Are you maybe still trying to renew an access token that has been renewed in the past? After renewing an access token, are you removing the old one from your database and adding the new token to it?

Matthew Mortimer (Xero Staff)