-
Notifications
You must be signed in to change notification settings - Fork 59
Renew the token for the public authentication #68
Description
Hi there,
It has been a tough task to find out where to ask this question. I presume that this channel would be the right address.
I would like to point out how I am connecting my software with Xero and how to renew the token which I haven't figured out yet. It is not a mvc app.
The following block is basically establishing the connection once the Xero page redirects back to my web app:
string verificationCode = Request.QueryString["oauth_verifier"];
string token = Request.QueryString["oauth_token"];
Session["xero_verification_code"] = verificationCode;
IOAuthSession oauthSession = IDispatch.COMMON.Xero.ServiceProvider.GetCurrentSession();
AccessToken accessToken = oauthSession.ExchangeRequestTokenForAccessToken(verificationCode);
var repository = IDispatch.COMMON.Xero.ServiceProvider.GetCurrentRepository();
For instance; the end-user has done his tasks and logs out the web app. After 10 min, he logs in back to the web app and wants to export another 2 invoices into Xero.
The system shouldn't redirect the page through Xero for the establishment, the system should let the user to do his task .
However, I cannot initialise the connection with Xero because my web app throws me an error for the request token etc...
Here is how i try to re-initialise the connection - However, it doesn't work.
AccessToken accessToken = new AccessToken();
accessToken.Token = "xxx";
accessToken.TokenSecret = "xxxx";
IOAuthSession session = ServiceProvider.GetCurrentSession();
var newAccessToken = session.RenewAccessToken(accessToken, accessToken.SessionHandle);
var repository = ServiceProvider.GetCurrentRepository();
// Get the organisation name from the api
var currentOrganisation = repository.Organisation;
Could you please help me out in regards?
Thank you a lot