How do you access the Google Apps Marketplace UserLicense from Apps Script (for a Sheets add-on)? -


i have sheets add-on need know users license information gam (appsmarket/v2/userlicense). since user logged sheets, wasn't expecting need use oauth, i'm getting 403 ("message":"not authorized access application id"). there way access license apps script without using oauth? here code far:

function testgetlicense(query) {    var options = {      'method' : 'get',      'contenttype': 'application/json',      'mutehttpexceptions' : true    };   var url = 'https://www.googleapis.com/appsmarket/v2/userlicense/1234/xxx@gmail.com'   res = urlfetchapp.fetch(url, options);   logger.log(res.getcontenttext()) } 

if need use oauth, should using library?

https://github.com/googlesamples/apps-script-oauth2

try passing oauth token in headers.

function testgetlicense(query) {    var options = {      'method' : 'get',      'contenttype': 'application/json',       'headers': {         "authorization": "bearer " + scriptapp.getoauthtoken()       },      'mutehttpexceptions' : true    };   var url = 'https://www.googleapis.com/appsmarket/v2/userlicense/1234/xxx@gmail.com'   res = urlfetchapp.fetch(url, options);   logger.log(res.getcontenttext()) } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -