Hi @MasterBlaster ,
According to my research and testing, please create a group and add access permissions, then use JSOM to add external users to this group in order to grant external users access to the SharePoint site.
Here is my test script,(See attachment) please refer to.
(When the button is clicked, the user is added to the group with access permissions)
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.