MDL-52051 oauth: expires_in is optional

This commit is contained in:
Andrew Nicols 2016-07-14 13:13:11 +08:00
parent d9520bc04e
commit 3a4c497c15

View File

@ -517,7 +517,10 @@ abstract class oauth2_client extends curl {
// Store the token an expiry time.
$accesstoken = new stdClass;
$accesstoken->token = $r->access_token;
$accesstoken->expires = (time() + ($r->expires_in - 10)); // Expires 10 seconds before actual expiry.
if (isset($r->expires_in)) {
// Expires 10 seconds before actual expiry.
$accesstoken->expires = (time() + ($r->expires_in - 10));
}
$this->store_token($accesstoken);
return true;