public function getScopes(SessionEntity $session)
    {
        $sql = <<<SQL
SELECT os.* FROM oauth_session oses
INNER JOIN oauth_session_scope oss ON(oses.id=oss.session_id)
INNER JOIN oauth_scope os ON(os.id=oss.scope)
WHERE oses.id = :sessionId
SQL;
        foreach ($this->getDbConnection()->fetchAll($sql, ['sessionId' => $session->getId()]) as $row) {
            if ($row) {
                return (new ScopeEntity($this->server))
                    ->hydrate([
                        'id' => $row['id'],
                        'description' => $row['description']
                    ]);
            }
        }
        return null;
    }