Skip to content
This repository has been archived by the owner on Nov 10, 2020. It is now read-only.

Renew the token for the public authentication #68

Open
mehmetaltuntas opened this issue Jun 10, 2015 · 0 comments
Open

Renew the token for the public authentication #68

mehmetaltuntas opened this issue Jun 10, 2015 · 0 comments

Comments

@mehmetaltuntas
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant