Google Drive API - Searching all shared file in a Drive with query - performance

I'm trying to find out which files in a shared google drive is shared with someone outside the organisation.
That includes :
shared with a public link
shared in domain
shared to someone by his email.
Here's an example of what I have without any filtering (post formatted)
[
{
"id": "XXXXXXXXXXXXXXX",
"name": "private but shared to external people",
"permissions": [
{
"id": "XXXXXXXXXXXXXXX",
"type": "user",
"emailAddress": "john.doe#anonymous.com",
"role": "writer"
},
{
"id": "XXXXXXXXXXXXXXX",
"type": "user",
"emailAddress": "admin#xxxxxxx.com",
"role": "organizer"
}
]
},
{
"id": "XXXXXXXXXXXXXXX",
"name": "public domain",
"permissions": [
{
"id": "XXXXXXXXXXXXXXX",
"type": "domain",
"role": "reader",
"domain": "xxxxxxxx.com"
},
{
"id": "XXXXXXXXXXXXXXX",
"type": "user",
"emailAddress": "admin#xxxxxxxx.com",
"role": "organizer"
}
]
},
{
"id": "XXXXXXXXXXXXXXX",
"name": "public",
"permissions": [
{
"id": "anyoneWithLink",
"type": "anyone",
"role": "reader"
},
{
"id": "XXXXXXXXXXXXXXX",
"type": "user",
"emailAddress": "admin#xxxxxxx.com",
"role": "organizer"
}
]
},
{
"id": "XXXXXXXXXXXXXXX",
"name": "private",
"permissions": [
{
"id": "XXXXXXXXXXXXXXX",
"type": "user",
"emailAddress": "admin#xxxxxx.com",
"role": "organizer"
}
]
}
]
To filter, I used the query: q: "visibility != 'limited'" but then the file
"private but shared to external people" isn't caught anymore.
So what I want is to create a query to retrieve all files that are shared and all files that are shared to any users that do not belong to the organisation.
I've already coded a manual version of that logic (this is why I can show the permissions array) but I would like to improve performances because it's really long to loop through all files to retrieves their permission and then manually check if the user email belongs to the domain or no.
Thank you :D

Related

Bot Framework save user data in the database by UserID

I want to save data that the user has entered in my database.
I need an ID that will be unique for all conversations with the same user rather than for a single conversation.
According to the documentation, I need to use the From.ID field from the Channel Account data.
But when I use Bot Framework Emulator and click Restart with same User ID, the ID of the user changes and what remains is the bot ID.
What field should I use to identify a user across different calls (in the same channel, of course)?
In this example, I see that the the Recipient.id identifier that the bot sends does not change.
Is this the user's unique identifier? Why is it be different from the From.ID?
Conversation 1:
Message from the bot:
{
"channelId": "emulator",
"conversation": {
"id": "202d2d60-4c7f-11e9-b1fa-8b3537dcca45|livechat"
},
"from": {
"id": "2",
"name": "Bot",
"role": "bot"
},
"id": "208f2380-4c7f-11e9-98ea-9595460a8f6e",
"inputHint": "acceptingInput",
"localTimestamp": "2019-03-22T10:47:30+02:00",
"locale": "",
"recipient": {
"id": "d4d1b5a6-1797-4d2a-b78e-257de71d3a69",
"role": "user"
},
"replyToId": "20559cf0-4c7f-11e9-98ea-9595460a8f6e",
"serviceUrl": "http://localhost:53634",
"showInInspector": true,
"text": "conversationUpdate event detected",
"timestamp": "2019-03-22T08:47:30.232Z",
"type": "message"
}
Message from the user:
{
"channelData": {
"clientActivityID": "15532445742330.iqwrgb646rq",
"state": "sent"
},
"channelId": "emulator",
"conversation": {
"id": "202d2d60-4c7f-11e9-b1fa-8b3537dcca45|livechat"
},
"entities": [
{
"requiresBotState": true,
"supportsListening": true,
"supportsTts": true,
"type": "ClientCapabilities"
}
],
"from": {
"id": "r_wg30czmqjt",
"name": "User",
"role": "user"
},
"id": "6a791af0-4c7f-11e9-98ea-9595460a8f6e",
"localTimestamp": "2019-03-22T10:49:34+02:00",
"locale": "",
"recipient": {
"id": "2",
"name": "Bot",
"role": "bot"
},
"serviceUrl": "http://localhost:53634",
"showInInspector": true,
"text": "hi",
"textFormat": "plain",
"timestamp": "2019-03-22T08:49:34.239Z",
"type": "message"
}
Conversation 2 (After Restart with same user ID):
Message from the bot:
{
"channelId": "emulator",
"conversation": {
"id": "a10fba20-4c83-11e9-b1fa-8b3537dcca45|livechat"
},
"from": {
"id": "2",
"name": "Bot",
"role": "bot"
},
"id": "a15611f0-4c83-11e9-98ea-9595460a8f6e",
"inputHint": "acceptingInput",
"localTimestamp": "2019-03-22T11:19:44+02:00",
"locale": "",
"recipient": {
"id": "d4d1b5a6-1797-4d2a-b78e-257de71d3a69",
"role": "user"
},
"replyToId": "a116e610-4c83-11e9-98ea-9595460a8f6e",
"serviceUrl": "http://localhost:53634",
"showInInspector": true,
"text": "conversationUpdate event detected",
"timestamp": "2019-03-22T09:19:44.271Z",
"type": "message"
}
Message from the user:
{
"channelData": {
"clientActivityID": "15532464069120.36lccv6nsg3",
"state": "sent"
},
"channelId": "emulator",
"conversation": {
"id": "a10fba20-4c83-11e9-b1fa-8b3537dcca45|livechat"
},
"entities": [
{
"requiresBotState": true,
"supportsListening": true,
"supportsTts": true,
"type": "ClientCapabilities"
}
],
"from": {
"id": "r_xl9pb24o5o",
"name": "User",
"role": "user"
},
"id": "aed62f90-4c83-11e9-98ea-9595460a8f6e",
"localTimestamp": "2019-03-22T11:20:06+02:00",
"locale": "",
"recipient": {
"id": "2",
"name": "Bot",
"role": "bot"
},
"serviceUrl": "http://localhost:53634",
"showInInspector": true,
"text": "hi",
"textFormat": "plain",
"timestamp": "2019-03-22T09:20:06.921Z",
"type": "message"
}
This was a bug in the Emulator, and fixed with https://github.com/Microsoft/BotFramework-Emulator/pull/1348
Please make sure you are on version >= 4.3.3:
Also, the Recipient.Id is the bot id if the message is coming from the Emulator.
Being that the bots do not track or identify a user, that part is up to you.
You will need to:
Create a "back channel" that captures Authentication of user. Give the bot access to the userid/username of the user who is interacting or having a conversation.
When the user logs in and authenticates to the application, you identify the user - retrieve this.
When the user interacts with the bot you get the conversation ID - you already have this.
Tie them together in a JSON object and store back to cloud storage, or app storage or SQL db.

Logic App deployment from Visual Studio 2017 fails

I have created a Logic App in Azure which works fine in Azure itself. So I first recreated the Logic App within VS2017 (with "Azure Logic Apps for Visual Studio" extension installed). The logic app contains a trigger to read from the Azure Servicebus and calls a custom logic app connector action. This custom connector calls a SOAP webservice via an Azure Data Gateway, which runs fine.
Now the issue is that when I try to deploy it from VS2017, it complains in the Output window. The message I get is:
New-AzureRmResourceGroupDeployment : 13:41:34 - Resource MICROSOFT.WEB/CONNECTIONS 'MyCustomConnector' failed with message '{"error": {"code": "ConnectionGatewayFailure","message": "Establishing connection with the service failed with code 'BadRequest'."}}'
My Logic App works great because I receive the SOAP request in my on-premise application.
What I have tried so far:
Checked my permissions, I am now owner of the resource groups (one where the Logic App and custom connector resides in, and one where the Gateway resides in)
Copied content in: "My resource group > Settings > Automation script > Json Template" and pasted it into Visual Studio
Run Visual Studio as Administrator
Added "-DeploymentDebugLogLevel All" to my Deploy-AzureResourceGroup.ps1 file, doesn't show me anything more useful.
Troubleshoot common Azure deployment errors which says for BadRequest: "You sent deployment values that do not match what is expected by Resource Manager. Check the inner status message for help with troubleshooting." I see no inner status message.
Checked Google for a useful answer
But up until now, without success. So hopefully some of you can help me.
Edit: Here's my ARM template, I renamed a few things, hopefully not too much.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"connections_servicebus_name": {
"defaultValue": "servicebus",
"type": "String"
},
"customApis_MyCustomConnector_name": {
"defaultValue": "My-Custom-Connector",
"type": "String"
},
"connections_MyCustomConnector_name": {
"defaultValue": "My-Custom-Connector",
"type": "String"
},
"workflows_MyLogicApp_name": {
"defaultValue": "My-LogicApp",
"type": "String"
},
"workflows_MyLogicApp_id": {
"defaultValue": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Logic/integrationAccounts/My-Integration-Account",
"type": "String"
}
},
"variables": {},
"resources": [
{
"comments": "Generalized from resource: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup-B/providers/Microsoft.Logic/workflows/My-LogicApp'.",
"type": "Microsoft.Logic/workflows",
"name": "[parameters('workflows_MyLogicApp_name')]",
"apiVersion": "2017-07-01",
"location": "westeurope",
"tags": {},
"scale": null,
"properties": {
"state": "Enabled",
"integrationAccount": {
"id": "[parameters('workflows_MyLogicApp_id')]"
},
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
},
"actions": {
},
"outputs": {}
},
"parameters": {
"$connections": {
"value": {
"My-Custom-Connector": {
"connectionId": "[resourceId('Microsoft.Web/connections', parameters('connections_MyCustomConnector_name'))]",
"connectionName": "My-Custom-Connector",
"id": "[resourceId('Microsoft.Web/customApis', parameters('customApis_MyCustomConnector_name'))]"
},
"servicebus": {
"connectionId": "[resourceId('Microsoft.Web/connections', parameters('connections_servicebus_name'))]",
"connectionName": "servicebus",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Web/locations/westeurope/managedApis/servicebus"
}
}
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/connections', parameters('connections_MyCustomConnector_name'))]",
"[resourceId('Microsoft.Web/customApis', parameters('customApis_MyCustomConnector_name'))]",
"[resourceId('Microsoft.Web/connections', parameters('connections_servicebus_name'))]"
]
},
{
"comments": "Generalized from resource: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup-B/providers/Microsoft.Web/connections/My-Custom-Connector'.",
"type": "Microsoft.Web/connections",
"name": "[parameters('connections_MyCustomConnector_name')]",
"apiVersion": "2016-06-01",
"location": "westeurope",
"scale": null,
"properties": {
"displayName": "LogicAppsCustomConnector-Connection",
"customParameterValues": {},
"api": {
"id": "[resourceId('Microsoft.Web/customApis', parameters('customApis_MyCustomConnector_name'))]"
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/customApis', parameters('customApis_MyCustomConnector_name'))]"
]
},
{
"comments": "Generalized from resource: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup-B/providers/Microsoft.Web/connections/servicebus'.",
"type": "Microsoft.Web/connections",
"name": "[parameters('connections_servicebus_name')]",
"apiVersion": "2016-06-01",
"location": "westeurope",
"scale": null,
"properties": {
"displayName": "worker_outbound",
"customParameterValues": {},
"api": {
"id": "[concat('/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Web/locations/westeurope/managedApis/', parameters('connections_servicebus_name'))]"
}
},
"dependsOn": []
},
{
"comments": "Generalized from resource: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup-B/providers/Microsoft.Web/customApis/My-Custom-Connector'.",
"type": "Microsoft.Web/customApis",
"name": "[parameters('customApis_MyCustomConnector_name')]",
"apiVersion": "2016-06-01",
"location": "westeurope",
"scale": null,
"properties": {
"connectionParameters": {
"authType": {
"type": "string",
"allowedValues": [
{
"value": "none"
}
],
"uiDefinition": {
"displayName": "Authentication Type",
"description": "Authentication type to connect to your API",
"tooltip": "Authentication type to connect to your API",
"constraints": {
"tabIndex": 1,
"required": "true",
"allowedValues": [
{
"text": "none",
"value": "anonymous"
}
],
"capability": [
"gateway"
]
}
}
},
"gateway": {
"type": "gatewaySetting",
"gatewaySettings": {
"dataSourceType": "CustomConnector",
"connectionDetails": []
},
"uiDefinition": {
"constraints": {
"tabIndex": 4,
"required": "true",
"capability": [
"gateway"
]
}
}
}
},
"brandColor": "#ffffff",
"description": "Calls My SOAP test webservice.",
"displayName": "[parameters('customApis_MyCustomConnector_name')]",
"iconUri":
},
"dependsOn": []
}
]
}

Accessing collections data from Google+ API

I'm using the Google Plus API, and there seems to be no information in the JSON response regarding the collection of the post. I was wondering if there was a way to access which collection a post belongs using the API data.
For example, could we use the URL given to parse the collection from the webpage? Does anyone have any idea how this could be done in a performant way?
The google+ api is a read only api and every limited it gives you access to people, activities and comments.
Activites list returns a list of all activities#resource posts by a user. try it
The only collection you can send is public. the response looks like this.
{
"kind": "plus#activity",
"etag": "\"RKS4-q7QGL10FxltAebpjqjKQR0/82jivrLU7ubQ-fwlLaXGSt3krb8\"",
"title": "",
"published": "2018-06-18T07:03:54.034Z",
"updated": "2018-06-18T07:03:54.034Z",
"id": "z13lu3vowpa5x3aws04chl2brzavs1rplos0k",
"url": "https://plus.google.com/+LindaLawton/posts/STgianNMQwU",
"actor": {
"id": "117200475532672775346",
"displayName": "Linda Lawton",
"url": "https://plus.google.com/117200475532672775346",
"image": {
"url": "https://lh5.googleusercontent.com/-a1CWlFnA5xE/AAAAAAAAAAI/AAAAAAAAl1I/UcwPajZOuN4/photo.jpg?sz=50"
},
"verification": {
"adHocVerified": "UNKNOWN_VERIFICATION_STATUS"
}
},
"verb": "post",
"object": {
"objectType": "note",
"actor": {
"verification": {
"adHocVerified": "UNKNOWN_VERIFICATION_STATUS"
}
},
"content": "",
"url": "https://plus.google.com/+LindaLawton/posts/STgianNMQwU",
"replies": {
"totalItems": 0,
"selfLink": "https://content.googleapis.com/plus/v1/activities/z13lu3vowpa5x3aws04chl2brzavs1rplos0k/comments"
},
"plusoners": {
"totalItems": 0,
"selfLink": "https://content.googleapis.com/plus/v1/activities/z13lu3vowpa5x3aws04chl2brzavs1rplos0k/people/plusoners"
},
"resharers": {
"totalItems": 0,
"selfLink": "https://content.googleapis.com/plus/v1/activities/z13lu3vowpa5x3aws04chl2brzavs1rplos0k/people/resharers"
},
"attachments": [
{
"objectType": "article",
"displayName": "leastprivilege/AspNetCoreSecuritySamples",
"content": "AspNetCoreSecuritySamples - Samples for various ASP.NET Core Security Features",
"url": "https://github.com/leastprivilege/AspNetCoreSecuritySamples",
"image": {
"url": "https://lh3.googleusercontent.com/proxy/1pdxjC-TsuF0-8yHOZKvfDOXG1pNWAIemDoW7OzrFy8pcckGqr0BTJj-TwgW9KgEuoGLJjfUKLWSCouJwTT7FjoOmZ_xURQwzz4=w506-h910",
"type": "image/jpeg",
"height": 910,
"width": 506
},
"fullImage": {
"url": "https://avatars0.githubusercontent.com/u/1454075?s=400&v=4",
"type": "image/jpeg"
}
}
]
},
"provider": {
"title": "Google+"
},
"access": {
"kind": "plus#acl",
"description": "Public",
"items": [
{
"type": "public"
}
]
}
},
the above post here is actually within one of my collections. But no were in the response does it mention the id of the collection that its in which is olLcVE
As i mentioned this is a very limited api and what you want to do is not available.

G Suite Account missing displayName parameter in Calendar API

I am creating an application that gets calendar events from Google Calendar using their API. I am not able to get the creator.displayName parameter for G Suite accounts, however. To rule out that it was something in my code I simply created a calendar Event from the calendar.google.com site and went to the API Explorer (https://developers.google.com/apis-explorer/#p/calendar/v3/calendar.events.list) to look at the event.
As it turns out, G Suite users don't have a displayName parameter but resources and standard Google Calendar users do.
For a G Suite Resource account I get something like:
{
"kind": "calendar#event",
"etag": "\"123456789220000\"",
"id": "<unique-ID-here>",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=unique-eid-link-here",
"created": "2018-02-27T13:00:07.000Z",
"updated": "2018-02-27T13:00:07.160Z",
"summary": "Event Name",
"creator": {
"email": "admin#gsuitedomain.com"
},
"organizer": {
"email": "gsuitedomain.com_uniqueidentifier#group.calendar.google.com",
"displayName": "A Resource Account",
"self": true
},
"start": {
"dateTime": "2018-02-27T05:52:00-08:00"
},
"end": {
"dateTime": "2018-02-27T06:00:00-08:00"
},
"iCalUID": "unique-uid-here#google.com",
"sequence": 0,
"reminders": {
"useDefault": true
}
And for a personal account I get:
{
"kind": "calendar#event",
"etag": "\"1234567890015265\"",
"id": "unique-id-here",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=unique-eid-here",
"created": "2018-02-27T13:00:04.000Z",
"updated": "2018-02-27T13:00:05.014Z",
"summary": "Event Name 2",
"creator": {
"email": "personal-gmail#gmail.com",
"displayName": "John Doe",
"self": true
},
"organizer": {
"email": "personal-gmail#gmail.com",
"displayName": "John Doe",
"self": true
},
"start": {
"dateTime": "2018-02-27T08:00:00-05:00"
},
"end": {
"dateTime": "2018-02-27T09:00:00-05:00"
},
"iCalUID": "unique-id-here#google.com",
"sequence": 0,
"reminders": {
"useDefault": true
}
}
Where the displayName is apparent under the organizer. But for the admin or any user in the GSuite I get the following:
{
"kind": "calendar#event",
"etag": "\"123459678950000\"",
"id": "unique-id-here",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=unique-eid-here",
"created": "2018-02-27T14:00:14.000Z",
"updated": "2018-02-27T14:00:24.391Z",
"summary": "Event Name 3",
"creator": {
"email": "admin#gsuitedomain.com",
"self": true
},
"organizer": {
"email": "admin#gsuitedomain.com",
"self": true
},
"start": {
"dateTime": "2018-02-27T07:30:00-08:00"
},
"end": {
"dateTime": "2018-02-27T08:00:00-08:00"
},
"iCalUID": "unique-id-here#google.com",
"sequence": 0,
"reminders": {
"useDefault": true
}
Am I missing something? Why don't G Suite users have the displayName parameter by default?
To anyone else who is struggling with this-
Individual user identity information is tied in with the Google+ profile that is created for that user. Google+ is enabled for the G Suite domain but the service has to be enabled for each user as well.
Once the G+ profile is set up the displayName will be available.

Bot Framework doesn't have username if telegram profile doesn't have full name or username

Messages delivered from Bot Framework don't have name property in from object if message was sent by user who doesn't have username and full name. For example if you delete first or last name from profile like that
Here's example of json that I get for messages sent from user that only has first name (look at from object):
{
"channelData": {
"message": {
"chat": {
"all_members_are_administrators": true,
"id": -219911672,
"title": "jlarky-dev",
"type": "group"
},
"date": 1493246056,
"from": {
"first_name": "Test",
"id": 107390199
},
"message_id": 100,
"text": "test"
},
"update_id": 66470785
},
"channelId": "telegram",
"conversation": {
"id": "-219911672",
"isGroup": true,
"name": "jlarky-dev"
},
"entities": [
{
"mentioned": {
"id": "JLarkyTestBot",
"name": "jlarky_test"
},
"text": "JLarkyTestBot",
"type": "mention"
}
],
"from": {
"id": "107390199"
},
"id": "KxBlE8JsLfg",
"recipient": {
"id": "JLarkyTestBot",
"name": "jlarky_test"
},
"serviceUrl": "https://telegram.botframework.com",
"text": "test",
"timestamp": "2017-04-26T22:34:17.4109674Z",
"type": "message"
}
Since #NilsW's comment I tested this again and it looks like from.name only exists when username of telegram profile was set (same can be looked up from channelData.message.from.username), so I guess it makes sense for it not to show username when username was not set :) and not having last_name part was not related here.

Resources