RingCentral Subscription Webhook With Google Script - google-apps-script

I'm trying to have RingCentral send information directly to my Google Sheet setting a subscription.
Using the function the RingCentral require to answer the initial request adding the validation token to the Validation-Token header which RingCentral sends in the same header. I can't find a way to access the header from the request I receive with doPost(e), and I don't know how to answer this request with the proper validation code so I basically cant close the loop and start using the registration.
Any idea?

Unfortunately Google Apps Scripts cannot access headers in doPost(e), even for Google's own x-goog prefix headers. You can follow the issue and feature request here:
https://issuetracker.google.com/issues/67764685
As a workaround, I wrote a service called "RingCentral Permahooks" that can be used as a go between between RingCentral and Google Apps Scripts by handling the validation token in the Permahooks service and also not-requiring it for the downstream service, Google Sheets Apps Scripts in this case.
https://github.com/grokify/ringcentral-permahooks

Related

How to get and send an OAuth token to Apps Script from an external service?

I'm attempting to make a post request from an Airtable script to Google Apps Script. I have a doPost() function set up in the Google Apps Script file, but the post request needs to be authenticated to run.
I believe I need to pass an OAuth token in the header of my request, but I'm unsure how to get this token in the first place. I've found this doc here about web apps in Google Apps Script but no luck finding how to generate an OAuth token from an external service.
I may be completely off the rails with my thinking, so if there's an easier way to make a post request and authenticate it from an external service, I'm all ears.
EDIT:
I don't really have any code at the moment. I'm using Postman to send the calls to Google to test. In Apps Script I have the following inside just to test.
doPost(e) { Logger.log("POST REQUEST") }
When I make the call from Postman, the function isn't triggered. In short, I know I need an authorization in the post request, but I don't know how or where to get it.

How to use Google ApiClient to pull Google Form and the responses (PHP)

Im use this Google ApiClient https://developers.google.cn/apps-script/api/quickstart/php
To pull Form & Responses, but same the api just add script to script.google
Please show me example to get the list form and Responses
Thanks
As of this writing there are no explicit REST APIs to pull Google Form data, so you won't be able to pull form responses directly from the Google API PHP client.
It you want to access form responses from PHP you'll need to use App Script to create a custom intermediary service/API that exposes the information you want.
You're already aware of the Apps Script API, so you can try creating a series of custom Apps Script functions to pull form responses and then call the Apps Script API from PHP to execute those functions to return the requisite data.
None of this is trivial to implement, and I don't have any code that I can share. But I'd start with reading the Apps Script API documentation and work out a solution from there.

Executing a Google Apps Script function from client side

I have created a Google Script that contains a main function I wish to call. Upon reading up on the documentation on this, I learn that, like any other API, an authorization token is required. I find and install Google's OAuth2 library directly into the Google Apps Script environment, and upon reading the documentation there, I am left asking: will the client need to login with their Google account to get an OAuth2 token, just to use my API? If not, how do I do such? (The API documentation doesn't quite explain how to accomplish this.)
I am ultimately trying to create a "Contact Us" form, in Angular, that hits this API.

Can I use Google Apps Script as Asana Webhooks endpoint (doPost)?

I'm trying to connect Google Docs with Asana. I can create tasks from Google Docs and save the connection to MySql database so I can display tasks inside Google Document.
Now I need those tasks to be synced with Asana all the time, so I wanted to create Asana webhooks. I created a doPost funtion in Google Apps Script which should serve as an endpoint. But when I initiate the starting handshake I don't receive a request from Asana to my Google Web App.
To be sure I'm doing everything right I also created a handshake in PHP, which I'm more familiar with. The only problem I had was a SSL certificate. But I think that shouldn't be the problem with Google. And also my Google Web App is public so there shouldn't be any restrictions (I tested it with Postman. I'm receiving requests from Postman. To be sure I receive a request I also created a log into a Google Document.)
What am I doing wrong?
Short answer:
Google Apps Script cannot be used as Asana Webhooks endpoint.
Long answer:
You can receive post requests to Google Apps Script with doPost function. So the first two steps of Asana Webhooks handshake can be accomplished. But there is no way to send a proper response for the third step of the handshake, because you can't read headers of the post request received from Asana and you also can't set the headers of the response back to Asana. Here is the answer I have found about reading and setting headers in Google Apps Script.

Through Google Apps Script get all user information on a spreadsheet of a google apps domain

I want to retrieve all the user data of my domain in a spreadsheet, so far i am able to retrieve first name email id last name ,storage quota and password change when next time i log in. But I am unable to get details like Apps enabled,License,Contact Sharing,Email Routing - Google Apps Email,Email Routing - Inherit routes , Mobile Devices,Date Snapshot,Date Change,Change Comment,Action done by etc.
I am basically not able to get any API for this all i am getting some JSON or XML codes but what if i entirely want it in GAS only no other files.
Some of what you are looking for is best requested via the Admin SDK. You may want to also check out other Google Data APIs in more detail, you could put together some good reporting tools.
Many of the APIs can be used in Google Apps Script by using the UrlFetch service. There's an OAuth flow built in that service that is quite nice for OAuth 1 flows, and it's not too bad to create a decent Google OAuth 2 flow with UrlFetch as well.
Then you can make authenticated requests to those APIs and handle the responses accordingly with Apps Script.