I am developing a web app that fetches and displays google analytics data for users that are not technical enough to do this themselves.
To do this, I:
1) have users log in with OAuth
2) store the access token
3) create a Google_Client and give it this access token
4) use this Google_Client to fetch the analytics data
This works no problem for the first user. However, it fails with an 'Access Denied' response for the second user. Following through the PHP code, I discovered that this is because the Google API Client caches the original access token (in the file system at /var/tmp/google-api-php-client), and uses this one instead of the fresh access token I have provided.
How do I prevent the Google API Client from caching the access token in the file system?
(Background information on the cache the Google_Client is using: when you provide an access token, it stores this with a key derived from the token scope. As the scope remains the same when the access token changes, the Google_Client does not create a new cache entry for each access token.)
NullGoogleCacheand then used it with$googleClient->setCache(new NullGoogleCache())- Joaquim d'Souza