I'm trying to let my users add me (using my email address) as a read-only user to their Google Analytics account via the Google Analytics API. In essence, they'd access my PHP page where it says: "Connect to Google Analytics" and they'd click on it, and give me read-only access - NOT JUST for this one time, but forever (unless they remove my email).
So far, I tried this:
$client = new Google_Client();
$client->setApplicationName('My App');
$client->setClientId('my client ID');
$client->setClientSecret('my client secret');
$client->setRedirectUri('my redirect URI');
$client->setDeveloperKey('my developer key');
$client->setScopes(array('https://www.googleapis.com/auth/analytics.readonly'));
My script receives a token just fine, but it can only access the data this one time. How can I make sure I can access the users Google Analytics data whenever I want?