Hi Deepinder Singh, welcome to the forum!
It is a pleasure to be able to help you.
Based on my understanding of the issue, I recommend creating a Provider-hosted SharePoint Add-ins app in SharePoint Server. You can refer to this documentation: SharePoint Add-ins
At the same time, you can improve the security and performance of your SharePoint sites by providing add-in app only tenant administrative permissions in SharePoint Online.
When you are developing SharePoint add-ins and want to register them using the ACS model (appregnew.aspx and appinv.aspx), you will need to follow a special process, when an add-in is requesting tenant admin permissions and in app-only mode.
You can refer to the documentation:
How to provide add-in app only tenant administrative permissions in SharePoint Online.
Granting access using SharePoint App-Only
Hope this helps.
Best Regards.
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.