These are instructions for getting the client ID and secret for oAuth.
This explains the process of navigating the Cloud Platform and getting your Apps Script project information including the client ID and secret.
An Apps Script project is initially given a "default" Google Cloud Project, but you will need to create a "standard" Google Cloud Project, and then associate the Apps Script project with the Google Cloud Project. To create a "standard" Google Cloud Project, you must first open the Google Cloud Platform dashboard at:
Google Cloud Platform
Then you need to create a new Cloud Platform Project, get the Cloud Platform Project id number, and add it to the Apps Script Project.
First go to IAM & admin, and choose "Manage resources"
Click "Create Project"
Create a project, and get the id number.
Go back to the Apps Script code editor, and open the Resources menu.
Enter the id number and associate it with the Apps Script project.
- In the "Resources" menu, choose the "Cloud Platform Project" item.
Dialog comes up:
Click Blue Link. Developers Console comes up. Navigate to Credentials.
In the Credentials page, click on either the Name or the "Edit OAuth Client" (pencil) icon.
Get the client ID and the client secret. You will need this for the oAuth authorization.
You must also enter a Redirect URI:
Quote from Eric Koleda's apps-script-oauth2:
Eric Koleda's apps-script-oauth2
Before you can start authenticating against an OAuth2 provider, you usually need to register your application and retrieve the client ID and secret. Often these registration screens require you to enter a "Redirect URI", which is the URL that users will be redirected to after they've authorized the token. For this library (and the Apps Script functionality in general) the URL will
always be in the following format:
https://script.google.com/macros/d/{PROJECT KEY}/usercallback
I think I understand your question and the problem you're facing. I've been working on auto-generated email notices with form edit URLs as well. You are correct that the script you've written is grabbing the URL for the last form submission (including edits) and not the URL for the response identified by date in your function. I'm not sure how you're capturing the URL for the confirmation emails, but I would recommend capturing the URL in another column of the sheet as the submissions come in. Then, you can just pull the URL value from the data array. I've used the following function to log all form submission URLs to a specific column:
function assignEditUrls() {
var form = FormApp.openById('insert form ID here');
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('insert sheet name here');
var data = sheet.getDataRange().getValues();
var urlCol = 10; // column number where URL's should be populated; A = 1, B = 2 etc
var responses = form.getResponses();
var timestamps = [], urls = [], resultUrls = [];
for (var i = 0; i < responses.length; i++) {
timestamps.push(responses[i].getTimestamp().setMilliseconds(0));
urls.push(responses[i].getEditResponseUrl());
}
for (var j = 1; j < data.length; j++) {
resultUrls.push([data[j][0]?urls[timestamps.indexOf(data[j][0].setMilliseconds(0))]:'']);
}
// populates the assigned column with all form response URLs to date
sheet.getRange(2, urlCol, resultUrls.length).setValues(resultUrls);
// gets the URL for the most recent form submission
var lastURL = sheet.getRange(resultUrls.length, urlCol).getValue();
Logger.log("URL Logged: "+lastURL);
return lastURL;
}
Best Answer
https://console.developers.google.com/apis/credentials/consent?project=project-id-#####
The "Privacy policy URL" input field is outlined by a red line.