Calling a Google Script web app only available to users inside domain from another Google Script -


i have google script deployed web app, unfortunately due company policy, have deploy , make available inside domain, not anonymous.

here's web app code

function dopost(e) {     var functionname = json.parse(e.postdata.contents).functionname;     return contentservice.createtextoutput(json.stringify({result:functionname}))     .setmimetype(contentservice.mimetype.json);   } 

here's google script code i'm trying call web app through it, tried pass access token in request header.

function callwebapp(functionname) {   var response = urlfetchapp.fetch(url, {     headers: {         "authorization": "bearer " + scriptapp.getoauthtoken(),     },     contenttype: 'application/json',     mutehttpexceptions:true,    method : 'post',     payload:json.stringify({functionname: functionname}),    });    logger.log(response)  } 

you can use session service , filter out users not in company domain.

for example:

var user = session.getactiveuser().getemail();  if(user.split('@')[1] === 'your.company.domain') {   //do } 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -