MDL-70430 oauth2: Fix storing of the new refresh token
authorDavid Mudrák <david@moodle.com>
Tue, 8 Dec 2020 10:20:14 +0000 (11:20 +0100)
committerDavid Mudrák <david@moodle.com>
Tue, 8 Dec 2020 10:24:27 +0000 (11:24 +0100)
There was a typo - missing underscore. As a result, the new refresh
token was never updated in the database. Depending on the issuer and
whether or when theyu invalidate issued refresh tokens, this might or
might not make the token refresh stop working.

lib/classes/oauth2/client.php

index 574ea94..6c49aaa 100644 (file)
@@ -473,7 +473,7 @@ class client extends \oauth2_client {
 
         // Store the access token and, if provided by the server, the new refresh token.
         $this->store_token($receivedtokens['access_token']);
-        if (isset($receivedtokens['refreshtoken'])) {
+        if (isset($receivedtokens['refresh_token'])) {
             $systemaccount->set('refreshtoken', $receivedtokens['refresh_token']->token);
             $systemaccount->update();
         }