Untitled UI logotext
Solutions
WebsitesEcommerceMobile AppsWeb AppsProduction Support & Maintenance
Our work
Company
About usBlogPodcastContact us
Book a free consultation

Keeping Google API sessions persistent with refresh tokens

Olivia Rhye

I've been working with Google's Tasks API and was looking to have a way a user would only need to authenticate their account once. Google does not explain very well on how to achieve this.

With php you will need to get the api setup HERE. You then need to then setup up an authentication stream:


require_once 'src/apiClient.php';
require_once 'src/contrib/apiTasksService.php';

$client = new apiClient();
$tasksService = new apiTasksService($client);

On the callback of the user allowing your app to access their tasks, you will get an access token and more importantly here a refresh token.


$auth = $client->authenticate();
$token = $client->getAccessToken();
$refresh_token = $token['refresh_token'];

Save the refresh token to somewhere you are able to access it again whenever you'd like. After that we can use that token to get the users tasks at any moment.


$client->refresh_token($refresh_token);

Ready to start a project?

Book a free consultation
Untitled UI logotext
Our work
About us
Blog
Careers
Submit a ticket
Agency Partnerships
Contact
© 2024 fjorge. All rights reserved.
Privacy