We can scan the Event Logs in all blocks to implement such a query.

The event Approval(address indexed _owner, address indexed _spender, uint256 _value) event will be triggered when the ERC20 contract is authorized.

When the (Approval) event is scanned, the authorization information of the relevant user is saved to the database.

The event Transfer(address indexed _from, address indexed _to, uint256 _value) event will be triggered when transferring money.

At this time, the allowance(address _owner, address _spender) method of the ERC20 contract is called to query the latest authorization information and then update the database.

From the genesis block scan to the latest block, all user authorization information will be saved in the database. After a transfer occurs on the chain, the latest authorization information will be updated to the database, so that all authorization information can be queried in the database.