I am working on some task automation from a Google Spreadsheet. I need to use Adobe Sign API to complete the process. I just started using AppScript last week, so I'm not sure if what I'm doing is right...
From the spreadsheet, I trigger a function that will open the oAuth request link of Adobe Sign to a new tab. User will sign in and click Allow Access. The redirect_uri I have setup is to the same spreadsheet so if the request is successful, it will redirect to the spreadsheet and the authorization code is included in the URL by Adobe Sign. (e.g. https://docs.google.com/spreadsheets/d/[spreadsheetId]/edit?code=[authorizationCode])
How do I get value for code parameter in the URL?
Adobe API reference for making an oAuth request - https://opensource.adobe.com/acrobat-sign/developer_guide/gstarted.html#create-an-authorization-request-link
I tried using e.parameter on onOpen event like below but its resulting into an error
TypeError: Cannot read properties of undefined (reading 'code') at onOpen
function onOpen(e) {
const code = e.parameter["code"];
console.log(code);
}
I have also tried implementing doGet(e), but not sure if I was doing it correctly. I'm getting error
TypeError: Cannot read properties of undefined (reading 'parameter')
I added a menu to trigger the doGet function:
function onOpen(e) {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Document control')
.addItem('Do Get', 'doGet')
.addToUi();
const code = e.parameter["code"];
console.log(code);
}
function doGet(e){
var code = e.parameter.code
console.log(code);
}
SpreadsheetApp.getActive().getUrl()should workparametervalue for "Code" (which is part of the URL). I think this involves adoPost(e)(or maybedoGet(e)) - you will know much more about this than me. Possibly related question?? doPost(e) does not return parameters but doGet(e) does?onOpenare limited and don't apply to" e.parameter. You need a different approach.