I'm using this great package to connect to the major social networks for authentication.
I probably don't fully understand the whole OAuth procedure but i get this error message when trying to connect to Google:
Error: the access token expired and no refresh token is available
I have two questions:
1. is there a way to refresh the token or once i get this error message there is nothing i can do?
2. I gather that i need to do all kinds of storing to a database, can you direct me to something I can read or can you explain the basics here?
|2013-09-08 23:02:10 - In reply to message 1 from Harel Mazor|
|Some servers like Google provide refresh tokens, others like Facebook don't.|
When they provide refresh tokens, the class attempts to refresh the token transparently when it expires during calls to CallAPI function.
If the server does not provide a refresh token, you need to ask the users to come to your site and so obtain a new token.
As for storing tokens in a database, you can use the database_oauth_client_class as base class, or evene mysqli_oauth_client_class if you use MySQL as database.
Read this article to learn more how to use those classes to store tokens in a database, so you can perform API calls when the user is not present.
|2013-09-09 15:59:32 - In reply to message 2 from Manuel Lemos|
|Thanks for you quick response,|
I'm currently in the building phase, and I created a button to call the "login_with_google.php" code.
this had worked fine until the token expired.
I'm not sure what I should do now that the token had expired...
I am, as a user, pressing this button and getting the expired error.
Since the server is not doing anything on its own i'm not sure what you mean by asking the user to come to my site.
|2013-09-09 18:27:02 - In reply to message 3 from Harel Mazor|
|When the token expires, it obtains a new one inside the CallAPI call, as long as it has obtained a refresh token too. This is achieved when you set the offline flag to true.|
|2013-09-10 11:56:02 - In reply to message 4 from Manuel Lemos|
|offline is set to true, the token had expired, and I get $success = false when calling $client->CallAPI(...)|
I'll check tonight if this is related to session variables but i think i already tried it...
in any case, you are saying that if I have a correct client id and secret it should work?
|2013-09-10 13:37:41 - In reply to message 5 from Harel Mazor|
|If you are always calling CallAPI after calling Process successfully, if the token expires, it attempts to renew the token, as long as you set the offline variable.|
|2013-09-10 18:29:25 - In reply to message 6 from Manuel Lemos|
|Thanks, it must have been something with the session variable.|
I returned home now, restarted FF and it started working again.
Thanks a lot for your dedicated help and reply,
Also, I wanted to know if the code can be used in a commercial application.
(I read the license agreement but could not understand it fully)
if so, is there something special I need to do? write something some where?
|2013-09-12 04:08:05 - In reply to message 7 from Harel Mazor|
|Yes, you can use that in commercial software. You just cannot claim that you developed the class code.|