Passing authentication from one Google Apps Script webapp to another Google Apps Script webapp

為{幸葍}努か 提交于 2019-12-05 12:46:54

I want to have Script B use UrlFetchApp to execute Script A. How do I authenticate Script B to Script A?

Even though Script A is set up to allow anyone to access it, our goal is to secure it so that only Script B will be able to make a valid request. This can easily be accomplished using a shared secret key that both Script A and Script B have access to. When Script B makes the request to Script A, it simply needs to include the secret key. Script A can refuse any request which does not include the secret key.

Only someone who is able to view the source code to either Script A or Script B will be able to find the secret key. Of course, anyone who obtains the secret key is able to impersonate Script B.

As a further enhancement, you could use the Utilities.computeHmacSha256Signature() method as a way to avoid sending the secret key as part of the request. Both scripts still need to know the secret key, but you can have Script B compute a signature and send that as part of the request instead of the secret key itself.

Without the anonymous access its not possible. You might be able to pretend you are a browser, ie see what your browser sends when you run the webapp and send the same header/cookie etc but its not really a supported way.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!