Files in Google Shared Drive not sending push notifications - google-api

I have been able to successfully create and receive webhook events for files in my personal drive, how ever when I try to set them up for a file in a shared drive I receive no events.
I get a status 200 when creating the webhook. So it seems that the webhook for file in the shared drive is being created properly. But after the initial 200 response no events follow no matter which changes to the file are made.
below is the request I have been using.
Perhaps this is a permissions issues but I can't find anything in Google's documentation on how to support push notifications in shared drives.
request({
method: 'POST',
uri:`https://www.googleapis.com/drive/v3/files/{fileId}`,
json: true,
body: {
id: '',
type: 'web_hook',
address: ``,
expiration: expiration_date,
},
headers: { Authorization: `Bearer` },
qs: {
includeItemsFromAllDrives: true,
supportsAllDrives: true,
supportsTeamDrives: true,
},
}),
```
Thanks

Related

How to make a HTTP request to a LocalNetwork from a HTTPS WebSite?

let's assume that there is a website under HTTPS, in that WebSite the user can set the IP of a local machine (thermal printer in this case). How can the user print something on that printer by using the website from his device?
The user have to use the WebSite only under the local network where the thermal printer is to be able to print.
The printer has a http server in it which it uses for the communication.
At this point how can a HTTPS website send a HTTP request to that local thermal printer?
Assuming you want this to be a variable that any user inputs,and that any user on any network has the ability to access their own printer, you would need it to be executed on the frontend. This way each user will be able to access the printer on their own network.
That gives you basically one option. Javascript. So if you wanted a stored request with some variables, you could have the javascript store variable from the DOM and then post a fetch request https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
Here is an example function
// Example POST method implementation:
async function postData(url = '', data = {}) {
// Default options are marked with *
const response = await fetch(url, {
method: 'POST', // *GET, POST, PUT, DELETE, etc.
mode: 'cors', // no-cors, *cors, same-origin
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
credentials: 'same-origin', // include, *same-origin, omit
headers: {
'Content-Type': 'application/json'
// 'Content-Type': 'application/x-www-form-urlencoded',
},
redirect: 'follow', // manual, *follow, error
referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
body: JSON.stringify(data) // body data type must match "Content-Type" header
});
return response.json(); // parses JSON response into native JavaScript objects
}
postData('https://example.com/answer', { answer: 42 })
.then(data => {
console.log(data); // JSON data parsed by `data.json()` call
});
You are likely struggling because of CORS.
You can find in depth discussion here https://javascript.info/fetch-crossorigin
In short, you will need to modify the fetch headers to have the correct credentials, mode, etc. as seen in the comments in the above snippet.

Slack API returns invalid_email error for valid email address

I am sending API request to undocumented API users.admin.invite to invite new team members to organization programatically.
But every time I send the request, it results in error invalid_email.
Which is weird, because if I fire the same request from https://{myorg}.slack.com/admin/invites it works.
I've managed to obtain the again undocumented client scope token, which is required for this. I've changed to content type to multipart/form-data, which seems to be required. But still it does not work..
The relevant code looks like this
const options = {
host: 'myOrg.slack.com',
path: `/api/users.admin.invite`,
method: 'POST',
headers: {
'Authorization': `Bearer ${config.slackAuthToken}`,
'Content-Type': 'multipart/form-data',
'Accept-Language': 'cs,en-GB;q=0.9,en;q=0.8',
'Accept': 'application/json',
'Cache-Control': 'no-cache'
},
formData: {
"email": event.email,
"first_name": event.firstName,
"last_name": event.lastName,
"real_name": `${event.firstName} ${event.lastName}`,
"set_active": true,
"resend": true, // Resend the invitation email if the user has already been invited and the email was sent some time ago
}
https.request(options) // simplified
It is a known bug of the undocumented API method admin.users.invite that some emails won't work (its also mentioned in the docs). Nothing much you can do about it I am afraid.
UPDATE
The problem was that the request must be send as application/x-www-form-urlencoded

How come I keep getting a "Request failed with response code 401" when trying to push via Urban Airship?

I have double, triple, and quadruple checked that I have the right master key that I'm passing. My parameters are taking directly from the UA website also so it can't be that. Anyone see what I'm doing wrong here???
Parse.Cloud.define("sendPush", function(request, response) {
var Buffer = require('buffer').Buffer;
var parameters = {
"audience" : "all",
"device_types" : "all",
"notification" : {
"alert" : "Hello from Urban Airship."
}
};
var params = JSON.stringify(parameters);
Parse.Cloud.httpRequest({
url: "https://go.urbanairship.com/api/push/",
method: 'POST',
headers: {
"Content-Type" : "application/json",
"Authorization" : 'Basic ' + new Buffer('MASTER_KEY').toString('base64'),
"Accept" : "application/vnd.urbanairship+json; version=3;"
},
body: params,
success: function(httpResponse) {
response.error(httpResponse);
},
error: function(httpResponse) {
response.error('Request failed with response code ' + httpResponse.status);
}
});
});
I've also tried adding in APP_SECRET:
"Authorization" : 'Basic ' + new Buffer('APP_SECRET':'MASTER_KEY').toString('base64'),
It's not clear from your code sample if you are including the app key in your request. API requests to Urban Airship use HTTP basic authentication. The username portion is the application key and the password portion in this case is the master secret. The application secret is restricted to lower-security APIs and is for use in the distributed application. The master secret is needed for sending messages and other server API requests.
Urban Airship provides a guide for troubleshooting common API issues.
I had the same problem and tried to figure it out by Network diagnosing tools for more than two days. Because after debugging I checked that I send the right credentials to UA. After all I called the UA and ask them to check the Credentials (in my case was appKey and appToken for streaming with java-connect API) if they are still valid. They checked and approved the validation but just in case sent me a new credentials. And I could connect with the new credentials!
It is for sure a bug by UA because I tested the whole time by another test application, which was a Desktop java application and I could connect to the server (with the same appKey and appToken) and get the events, but I got 401 error in my main Application, which was a Web Application running on TomCat 8.0 . It means It worked in a same time in with the same credential for one application and did not work for another application.

Mobile Hybrid application throws 500 error for all POST requests to JIRA Server

I have a Hybrid application using cordova and angular that utilizes the JIRA rest service. I am doing a simple call to add a comment to a JIRA ticket using ajax. All calls were working until the recent upgrade to JIRA 7. After the upgrade all calls except POST still succeed.
var data = {
"body": "quick comment",
};
var req = {
method: 'POST',
url: 'https://our.jiraserver.com/jira/rest/api/2/issue/{issuekey}/comment',
headers: {
'Authorization': 'Basic garbeldygoopasdfasdf',
'Content-Type': 'application/json',
'Access-Control-Allow-Origin':'*'
},
data: data
};
$http(req).then(function(response){
console.log('success', response);
}, function(error){
console.log('errpr', error);
});
A trimmed version of the error the server is throwing (for those TL;DR's)
message: "Expected authority at index 7: file://"
stack-trace: "java.lang.IllegalArgumentException: Expected authority at index 7: file://↵ at java.net.URI.create(URI.java:852)↵ at com.atlassian.applinks.cors.auth.DefaultCorsService.getApplicationLinksByOrigin(DefaultCorsService.java:56)↵ at com.atlassian.applinks.cors.auth.AppLinksCorsDefaults.allowsOrigin(AppLinksCorsDefaults.java:42)↵ at com.atlassian.plugins.rest.common.security.jersey.XsrfResourceFilter$1.apply(XsrfResourceFilter.java:255)↵ at com.atlassian.plugins.rest.common.security.jersey.XsrfResourceFilter$1.apply(XsrfResourceFilter.java:252)↵ at com.google.common.collect.Iterators.indexOf(Iterators.java:778)↵ at
I will note again these calls worked until very recently... as a workaround I setup a node/express servers to simply bounce my api calls through. I send the data there, it makes the same request and succeeds and passes the data back to my app. Of course this isn't ideal as I now have a split code base.
I went to Atlassian support who basically told be they cannot assist with third-party development.
Any suggestions or help would be greatly appreciated.

upload directly to aws s3 using fineuploader

I am using below code to upload files to S3 with JS. Don't know what's going on wrong here. Any help will be highly appreciated..
request: {
endpoint: "https://photoform.s3.amazonaws.com",
inputName: 'name',
forceMultipart: false,
paramsInBody : true,
filenameParam : 'test',
params: {},
accessKey: "AKIAIM5CBG3WFLLZBTAA"
},
signature: {
//always included
"expiration": "2014-02-04T14:32:31.373Z",
signature : "Bv7MiXh5LM4nQGcK0HVgu27DmQE=",
policy: "eyAiZXhwaXJhdGlvbiI6ICIyMDE0LTAyLTA0VDE0OjMyOjMxLjM3M1oiLCJjb25kaXRpb25zIjogWyB7ImJ1Y2tldCI6ICJwaG90b2Zvcm0iIH0gLHsgImFjbCI6ICJwdWJsaWMtcmVhZCIgfSx7IkNvbnRlbnQtVHlwZSI6ImpwZyJ9LHsic3VjY2Vzc19hY3Rpb25fcmVkaXJlY3QiOiJodHRwczovL2NzMzAuc2FsZXNmb3JjZS5jb20vYXBleC9MaXN0U2xpZGVyVXBsb2FkUGljc1N1Y2Nlc3MifSxbInN0YXJ0cy13aXRoIiwgIiRrZXkiLCAiIl0gXX0=",
"conditions":
[
//always included
{"acl": "public-read"},
//always included
{"bucket": "photoform"},
//not included in IE9 and older or Android 2.3.x and older
{"Content-Type": "jpg"},
//always included
{"key": "AKIAIM5CBG3WFLLZBTAA"},
//always included
{"x-amz-meta-qqfilename": "test.jpg"},
]
},
cors: {
expected: true, //all requests are expected to be cross-domain requests
sendCredentials: false, //if you want cookies to be sent along with the request
allowXdr: true
},
Please read through the documentation on the docs site that explains how to use Fine Uploader S3. The signature option is not where you create your policy document. Instead of hard-coding the policy document and signature in the signature option, you must specify an endpoint where Fine Uploader will send the policy document it creates. Your server is expected to sign it and return the signature.
Useful links:
Creating a server for Fine Uploader s3
Fine Uploader S3 signature option

Resources