diff --git a/src/Module/BaseApi.php b/src/Module/BaseApi.php index 87d0838c5..739d400e3 100644 --- a/src/Module/BaseApi.php +++ b/src/Module/BaseApi.php @@ -28,6 +28,7 @@ use Friendica\Database\Database; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Network\HTTPException; +use Friendica\Util\DateTimeFormat; require_once __DIR__ . '/../../include/api.php'; @@ -218,7 +219,7 @@ class BaseApi extends BaseModule $code = bin2hex(openssl_random_pseudo_bytes(32)); $access_token = bin2hex(openssl_random_pseudo_bytes(32)); - $fields = ['application-id' => $application['id'], 'uid' => $uid, 'code' => $code, 'access_token' => $access_token]; + $fields = ['application-id' => $application['id'], 'uid' => $uid, 'code' => $code, 'access_token' => $access_token, 'created_at' => DateTimeFormat::utcNow(DateTimeFormat::MYSQL)]; if (!DBA::insert('application-token', $fields, Database::INSERT_UPDATE)) { return []; } diff --git a/src/Module/OAuth/Token.php b/src/Module/OAuth/Token.php index 3cb59a4c1..6e574a8af 100644 --- a/src/Module/OAuth/Token.php +++ b/src/Module/OAuth/Token.php @@ -61,6 +61,7 @@ class Token extends BaseApi DI::mstdnError()->RecordNotFound(); } - System::jsonExit(['access_token' => $token['access_token'], 'token_type' => 'Bearer', 'scope' => $application['scopes']]); + // @todo Use entity class + System::jsonExit(['access_token' => $token['access_token'], 'token_type' => 'Bearer', 'scope' => $application['scopes'], 'created_at' => $token['created_at']]); } }