Create a transaction for prog1 (tcode1) and another for prog2 (tcode2). In prog1, you code a CALL TRANSACTION 'tcode2'. In prog2, you code IF sy-tcode <> 'tcode1'. EXIT.
-> You can only ever run prog2 from tcode1, and in that case don't need authorizations for tcode2.
No dynamic authorizations mechanism needed.
Cheers,
Julius