Submitting form data to Google Sheets without OAuth

I’m working on a web form and want to send the data straight to my Google Sheet. The problem is, I can’t figure out how to do it without OAuth2. Every time I try to submit the form, that Google login screen pops up. It’s driving me crazy!

Is there any way to skip the OAuth part and just post to my own sheet? I really don’t want users to see that Google screen. I’m okay with a server-side solution if needed - I’m using PHP.

Here’s a basic example of what I’ve tried:

function postDataToSheet($info) {
  $sheetIdentifier = 'sheet_id_example';
  $cellRange = 'Sheet1!A1:C1';
  
  $dataPayload = new Google_Service_Sheets_ValueRange([
    'values' => [$info]
  ]);
  
  $options = [
    'valueInputOption' => 'RAW'
  ];
  
  $response = $sheetsService->spreadsheets_values->append($sheetIdentifier, $cellRange, $dataPayload, $options);
  return $response;
}

But this still requires OAuth. Any ideas on how to bypass it? Thanks for your help!

hey tom, try google apps script as a web app endpoint. use a simple post from php to send your form data, bypassing oauth. works well for me!

I’ve encountered similar challenges before. One solution is to use Google Apps Script to handle form submissions. You can create a project linked to your spreadsheet and write a function that responds to POST requests, appending the received data directly into your sheet. Once you deploy the script as a web app accessible to anyone, your PHP code can use cURL to send data without triggering OAuth on the user side. This method bypasses the authentication prompt, as the script executes under your account’s permissions. It is also advisable to validate and sanitize all incoming data to maintain security.

Using Google Apps Script as an intermediary has worked well for me. I created a new Apps Script project in my Google Sheet and implemented a doPost(e) function that appends incoming data to the sheet. After deploying the script as a web app with permissions that allow public access, my PHP code can send a simple POST request via cURL without triggering any OAuth prompts. This method avoids the OAuth hassle and has been reliable for months now. Just make sure to implement basic security checks to prevent any potential abuse.