How to detect if an email is a Google Account?

前端 未结 6 1509
一向
一向 2021-02-19 12:16

Me and some guys here are working on an start up. We are currently using Google OpenID API to manage registration and login to our app, but we want to migrate to a easier user r

6条回答
  •  广开言路
    2021-02-19 12:35

    I worked out Doug's suggestion and it works. Just make sure that the (effective) user invoking the function has the right to call addViewer. A trick to accomplish this is to make sure the routine is called from a trigger routine, so the owner of the script is the effective user.

    function checkIfGoogleAccount(emailAddress) {
      try {
        SpreadsheetApp.getActiveSpreadsheet().addViewer(emailAddress) ;
        SpreadsheetApp.getActiveSpreadsheet().removeViewer(emailAddress) ;
        return true ;
      }
      catch(err) {
        return false ;
      }
    }
    

提交回复
热议问题