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.
Related
I was using google sheet from one application using htttp request like https://script.google.com/macros/s/XXXXXXXX/exec
but now Google has changed the access method. now I cannot access the URL mentioned above (XXXXXXXX : Replaced with my sheetid).
Now I was searching the access method and I found that we can also access using google API keys. which has to send in the HTTP request. Here is the page for more information.
https://developers.google.com/youtube/v3/guides/auth/server-side-web-apps#httprest_1
But I am not getting a complete idea for HTTP request.
Anyone has tried the same or related.
From the question
I was using google sheet from one application using htttp request like https://script.google.com/macros/s/XXXXXXXX/exec but now Google has changed the access method. now I cannot access the URL mentioned above (XXXXXXXX : Replaced with my sheetid).
The XXXXXXXX is not the the sheetid, it's a unique id assigned to the corresponding web app deployment.
To get the web app full URL you have to go to your script, using the new Google Apps Script IDE, click on Deploy > Manage Deployments then select the corresponding deployment.
Resources
https://developers.google.com/apps-script/guides/web
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.
I have used Apps Script successfully on many occasions, and one of the reasons I like it, especially for personal enhancements or projects related to Google Services is just how seamlessly it integrates auth. However, when trying to integrate the YouTube Data API into one of my Google Sheets' Apps Scripts (I am trying to use the sheet to manage a YouTube playlist), I encountered an error that I have never encountered before.
The code is very simple, I am just trying to get some data from a playlist to return to the logger in the context of my Google Sheets Apps Script. Note that this Apps Script belongs to the same account as the YouTube playlist. The OAuth Client Verification docs specifically state:
Note: Verification is not required for Apps Script projects whose
owner and users belong to the same Google Workspace domain or
customer.
However, when I run my script, the OAuth screen says the app is unverified (this has never happened when I have used any other APIs accessing my own account in Apps Script), and even though I authenticate and it says "Authentication Successful", the script is blocked and it repeatedly (as in forever, in an endless loop) asks me to authenticate again.
Completely at a loss for what is going on. 1.) I shouldn't have to verify this script per the docs I referenced above, and I have never had to before for accessing my own content. 2.) The successful authentication but then failing and repeatedly asking me to authenticate again is driving me mad.
Please advise!
Code is very simple, just trying to get this to return ANYTHING:
const syncVideos = () => {
let response = YouTube.PlaylistItems.list('snippet,contentDetails', {'playlistId': '<REDACTED>'});
Logger.log(response);
}
Answer: This turned out to not be a code or OAuth issue really, but more of an unintuitive procedure when authenticating, i.e. when authenticating with Google to access one of your channel's data through the YouTube Data API, authenticate with your main channel, even if requesting data from other channels connected to your account.
I am attempting to remotely execute a google apps script function using the apps script api through a postman request.
I first get credentials from the Google API Playground
Then they are inputted into postman as OAuth2 credentials, and inputted in the headers like this:
Then the appropriate link is requested:
Then the body prepared:
And then the response after making the request:
Postman is returning an error 403, which, according to Google's documentation
indicates that "the Cloud Platform project used to authorize the request is not the same as the one used by the script." An error 403 is an authorization error and can mean many things, but let's assume that the error is what google proclaims it to be.
I have full control over the GCP project utilized by my script, but I'm not aware of where to find the project that was used to authorize the request.
Where might I gain access to this GCP project so I can assign my script to this project, thereby eliminating the 403 error?
Thanks!
To use OAuth Access Tokens from the OAuth Playground with Apps Script, you need to specify the correct Client ID and Client Secret from the same project.
In the OAuth Playground. Click on the gear icon (top right). Select "Use your own OAuth credentials". Then enter the Client ID and Secret ID created in the same project as Apps Script.
To query a Google URL using a valid Access token with Postman you can log the access token from apps script and use it after.
In your apps script after validating scope, i.e. running a first time the script, log the token :
function logToken(){
Logger.log(ScriptApp.getOAuthToken());
}
Then in Postman query the Google URL by setting in the header the access token :
"Authorization": "Bearer THE_ACCESS_TOKEN"
Security warning : for security reason I have to tell you that an access token is valid 1 hour so technically if you grant full drive scope to your app with this access token we can browse all your Drive.
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