Sorry, there is no way to do this
From what I understand, you want to be able to:
- Send a normal spreadsheet link to someone.
- Have that link redirect to your own login page.
- Once user logs in, then redirect them to the spreadsheet.
Further I believe you want the spreadsheet to be inaccessible to the user unless they are logged in.
This is not possible. There is already a log in system, and that is Google's. You share the spreadsheet with who you want to share it with, and then they need to log into their Google account to access it.
If this is your team, then you should probably look into a Workspace account as this has more functionality that you may be looking for, like the ability to identify the user who is accessing your spreadsheet, if they are in your domain.
Ideas for workarounds
- You could send a link to a web app instead, and then have that redirect them, or provide a link to the spreadsheet. However, once they have the link, they will have the link and can bypass the login screen.
- You could embed the spreadsheet, so it appears on your web app. However, it is quite easy to find the URL, and further, the sheet needs to be public if you want to embed it.
- Create a form on your web app. Depending on how much information you have, you could translate it to HTML with Client-to-server communication, that is, sending messages between the client side HTML and JS and the "back end" Apps Script. This is a good way to totally hide and secure your spreadsheet link, however, you will need to implement all of the viewing and editing functionality yourself.
Reference
Edit
Your idea of using something like window.close();
as part of the onOpen
function will not work.
This is because the HTML of a popup is loaded in an iframe. This is similar to a web page inside a web page. The problem is that these iframes have strict security policies that prevent the JavaScript within it to access anything outside of it.
You can try calling window.parent
on the iframe but it will give you the popup, and then if you call window.parent.parent
you will get:
