How to trigger a github webhook from Dropbox - github-actions

Dropbox gives the possiiblity to create a webhook here that is sent when a file is added to a folder. Reading the doc it seems that you can't configure much the information that are sent and there is also a verification procedure the client should match.
The client is github, in particular I want to trigger a job in continuos integration (github actions) when a file is added in a Dropbox folder.
I solved used a third party service, in this case Zapier, which is similar to IFTTT, but it is not free to send raw http post (which actually it is the simpler thing they offer...)
Is there an easy way to achieve what I meant, without using a third party service, and without querying Dropbox continuosly to check for new files?

Related

How do get the url "https://script.google.com/macros/d/{SCRIPT ID}/usercallback" responding / up and running

I'm a beginner in Google Apps Script.
I'm basically trying to use the OAuth service in a Google Apps Script to be able to connect a Google spreadsheet to Yahoo fantasy API.
I'm using the package you can found here:
https://github.com/googleworkspace/apps-script-oauth2
In the "read me" part you can see that oauth libraries will by default use the callback url https://script.google.com/macros/**d**/{SCRIPT ID}/usercallback
So I try to use this package in my script, but when I publish my script it creates the following url:
https://script.google.com/macros/**s**/{SCRIPT ID}/
Notice it's an "s" instead of the "d" in the url.
I can access properly to https://script.google.com/macros/**s**/{SCRIPT ID}/exec and so on but the url containing the "d", which is expected to be use by OAuth service, return an error.
When trying to access the url in a browser I got:
an error if I call ../usercallback
the message: "Sorry, the file you've asked doesn't exist", if I call the ../exec
.. is https://script.google.com/macros/**d**/{SCRIPT ID} in that case.
I've been looking on internet for having this url working but no success (it that so obvious that no one else had the issue except me?).
I tried several thing, i've created a project and linked my script to that project, i played a bit with the configuration in the project in regards to what i found on internet, like credential for API, but still can't have the url with a "/d/" responding.
I'm not sure of the meaning of the "s" (script?) or the "d" in the url.
I'm not sure if it has something to do with the way I publish my script or if I need to have specific function in my script or maybe some configuration of the script, maybe I need to persevere with the project thing...
I think that you should re-read the Readme.md file from the Google OAuth Sample GitHub repo. Also I think that d and s parts of Google Apps SCript URLs are irrelevant for using the "OAuth Service".
The .../exec URL is generated when making a new deployment. This URL doesn't contain the script Id... please bear in mind that a single Google Apps Script project might be deployed multiple times and have all or some deployments being live at the same time. Each web app deployment will have it's own URL... none of them have the script id. By the other hand, you might not need to make a deployment in order to be able to use "the OAuth service", this is needed only if the script will be receiving GET/POST HTTP requests.
You should not to access the ../usercallback in the browser, as you will be doing a GET request without proving the required data. This URL should be added when getting the credentials to be used with the "OAuth Service" from the OAuth provider, in this case Yahoo, as the redirect URI.
The referred repo includes multiple samples about how to use the "OAuth Service", one of the is Yahoo.gs
Resources
https://developers.google.com/apps-script/guides/web
https://developers.google.com/apps-script/concepts/deployments

How to test WebHooks without an on-premise external system?

I'm trying to teach myself about integrating systems via WebHooks.
In a free/hosted GIS system, I can create a WebHook that would, in theory, POST a JSON object to an external system.
The problem is, I don't have an external system that's available right now for for receiving the POST.
I think I need some sort of publicly available sample server that would:
Receive the POST requests
Do something with the requests (ie. create some sort of record)
...so that I could determine if the WebHook worked correctly or not.
How can I test my WebHooks without having an on-premise external system?
I've poked around websites like Postman Echo and Amazon Lambda. But to my untrained eye, it seems like they're not quite designed for what I need.
You could use any of these options depending on your requirements:
You could use webhooks modules in services like Integromat or Zapier to receive webhook data and then apply transformation.
You could deploy a script on heroku and use the URL generated there to send the webhooks calls.
You could also use services like requestbin, webhook.site etc if you just want to receive webhooks data.
Regards

Ejabberd 17: How to create a hook which is called for offline messages?

I want to create a hook which is called whenever an offline message is created. Example: user-a(online) send a message to user-b(offline). Then as per ejabberd the message is stored and sent when user-b comes online. But in this situation, I want to call a local server POST URL with the data. How to create such a hook?
This hook is created so that I can from the local server send a push notification. Thus whenever a user comes online he/she will get the offline message as the push notification.
There is no step by step implementation for this. If anyone knows this it will be of great help.
There are two hooks called when a message is sent to a local account that is offline: ejabberd_sm calls offline_message_hook. And mod_offline calls store_offline_message. Search for that in the ejabberd source code, and you will find example code to use them.
Building on Badlop's answer, I have created a module that does exactly what you need to achieve from an offline_hook. Only with a difference that you'll have to connect a component to ejabberd instead of getting messages on REST API.

Drive push messages - spammed by notifications

I am currently developing system synchronizing files between Google Drive and external storage. I am trying to process push notifications. I was already able to register for them and receive them. After receiving each notification, I acquire list of changes using proper endpoint and try to get a new version of file if necessary, so the flow is like that:
Subscribe to notifications using changes.watch
Receive some push message with url to changes
Use API with provided query to get changes on changes.list endpoint
Filter items that changed after particular moment
Get content of file and transfer it to another service
It seems that after initial notify message, Google starts spamming a new one, always after getting file. I suspect that the action of getting file content is changing some timestamp on file and therefore - its content is changed.
Is it possible not to modify file in any way when getting its content?
EDIT:
It seems that this behaviour concerns files.export endpoint as well - Exporting Google Doc as PDF leads to notifications spam too. Commenting out export part in a code stops them from coming.
You're getting spammed since Changes: watch listens more to changes made by a user, not the file itself.
What you need to use in this scenario is Files: watch. It subscribes you to listen to changes to the file itself.

Google Drive API says some files do not exist when in fact they do

So, I've gotten to the point in my app where I can retrieve a list of spreadsheet documents from a user's Google Drive account by using the Google Spreadsheet API. I populate the file list in a ui control that users can click on to then retrieve the list of its worksheets. It's working as expected in some cases, but in others it is not. In my request, I use the url that comes back from the file list, and even so, the API responds with:
Sorry, the file you have requested does not exist.
Make sure that you have the correct URL and that the owner of the file hasn't deleted it.
Well, surely the file wasn't deleted. I got it back in the response to my request for the files list. I also can get to the file via a normal web browser. Also, the URL is correct because that's the one the API responded with. My code does not manipulate the url that comes back in that initial files response. In fact, here is the URL that is used to grab the worksheets:
https://spreadsheets.google.com/feeds/worksheets/{long key here}/private/full
So, my question is why does my request for some worksheets come back with a response with the actual list of worksheets, but on others (which I have access to, and I know exists) I get the faulty response.
Thanks,
Arie
My app is using OAuth 2.0 and I ran into the same error with new Google Sheets. What fixed that was making a change in scope param sent during OAuth's authorize call and then reauthorising (reinitiating OAuth flow and obtaining new tokens).
Until now scope in my app was just:
https://spreadsheets.google.com/feeds
Updated scope and solution to the issue in my case:
https://spreadsheets.google.com/feeds https://docs.google.com/feeds
I'm running into this in my own stuff. At least for what I'm running into, it seems to be an issue with New Sheets. I'm sorry to not have more of a solution (I'm still trying to find out what to fix on my end) but this may help you narrow down the issue.