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?
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
Post a Comment