Login   Register  
PHP Classes
elePHPant
Icontem

re-using oauth access token

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      PHP OAuth API  >  All threads  >  re-using oauth access token  >  (Un) Subscribe thread alerts  
Subject:re-using oauth access token
Summary:re-using oauth access token
Messages:3
Author:john smith
Date:2013-04-17 07:56:32
Update:2013-04-17 23:40:31
 

  1. re-using oauth access token   Reply   Report abuse  
Picture of john smith
john smith
2013-04-17 07:56:32
Hi, I am sure this is a common scenario but how do I re-use the access_token? I used login_with_dropbox.php ran it once and then hard coded the access token and secret before $client->Process() is called (and also set 'authorized' to true)

This all seem fine but when I try it, it doesn't work in different browser and also if same browser is restarted (close, then launch again) it won't work either.

  2. Re: re-using oauth access token   Reply   Report abuse  
Picture of john smith
john smith
2013-04-17 08:10:48 - In reply to message 1 from john smith
After some debugging modifying the token values before calling Process() is not good enough. If I hard coded the token values inside of GetAccessToken then it works fine. This works so I am happy.

  3. Re: re-using oauth access token   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2013-04-17 23:40:31 - In reply to message 1 from john smith
The Process function is just for authorizing and retrieving the access token.

Once you have retrieved the access token already you do not need to call the Process function anymore unless the token becomes invalid for same reason.

Just set the access_token and access_token_secret variables and use the CallAPI function to call the API.

The reason why using the Process function only works with the same browser is because it uses sessions to store the access token in session variables. You need to create a sub-class and override the GetAccessToken and StoreAccessToken to store and retrieve token values in a more persistent storage like a database.