I'm writing a Wordpress plugin which displays visits on a page. Everything's done and it works perfectly... for an hour. I can't refresh the token when it expires, so the end-user can't see Analytics results. I don't know what am I doing wrong, maybe I misunderstood the authentication process.
This is how I manage the first connection to the API:

Have you tried with the newer version of the library that is on GitHub? I have a project that do the refreshing the same way you're doing here and it works fine. The code changes required to migrate to the new lib are minimum.
– Vinicius PintoApr 4 '14 at 20:11

I tried it, and the error still occurs. Any other idea?
– user3498531Apr 7 '14 at 12:57

not really, the error is about setting client assertions, but you're not doing it anywhere in the code you posted
– Vinicius PintoApr 7 '14 at 15:07

Problem solved. I had an error in code related with Wordpress forms and saving options. Also I figured out, that there's no need to call the function refreshToken(). It refreshes itself if needed when you assign it with setAccessToken().
– user3498531Apr 11 '14 at 14:48