Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Getting Started >

can logon, can perform verifier, but then still authentication issue

Started by albert drent -   in Getting Started

Sorry being a totally new user to this api. Perhaps this question is a stupid one:
I'm trying to create a bootstrap form app from the php sample. This sample uses 3 steps, the initial one to logon, a second one to do the verifier and the third one to perform the api. All in one php file.
In my sample I have two files, an initial logon and a second one. In the second form I have a button that will perform the verifier and because I don't see why to relocate again I perform the api just after validating the verifier. All goes well but calling the api generates an authentication error: Token KKX7IJJEQ9UQRUJS1WXSJ2TH4E5RAM does not match an expected ACCESS token in C:.....etc. What am I doing wrong?
It's important to look good into the code to find out what is going wrong. Fact is that the sample application is not so clear if you want to transform that into a form application, and it's not necessary to perform all those redirects to itself performing several stages. But after retrieving a next set of tokens after using the verifier, the global variables are set to the new tokens. However, the current session is not changed and when you call the api you get above error. If you follow the same approach as the sample it will work as it will retrieve the tokens from the session initially, but if you don't want to do a redirect you must simply overwrite the current session variables.
 

albert drent