How to get data from Google's Report API in stream - google-drive-api

I'm using the following code to get drive log data from ReportsAPI:
SCOPES = ['https://www.googleapis.com/auth/admin.reports.audit.readonly']
DELEGATION_ACCT = 'xxx'
creds = service_account.Credentials.from_service_account_file(self._config['googletools']
['credentials-file'],
scopes=SCOPES)
delegate_creds = creds.with_subject(DELEGATION_ACCT)
service = build('admin', 'reports_v1', credentials=delegate_creds)
drive_logs = service.activities().list(userKey='all', applicationName='drive').execute()
And that returns me a list of drive logs.
I would like to get the same result but from stream, so that I could get the logs in a continues way

Related

Deluge function to get a Postcode and put the street name and city into the Address field on Zoho CRM

I'm trying to write a code that'll automatically run when a contact is created. It'll take the postcode and use that with my Google Geocoding API to pull the street and city, and put that in the Address field.
leadDetails = zoho.crm.getRecordById("ARCH_Concept_Ltd",input.leadId);
// Make API call to Google Maps Geocoding API
api_key = "API_Number";
postcode = ifnull(leadDetails.get("Postcode"),"");
api_url = "https://maps.googleapis.com/maps/api/geocode/json?address="+postcode+"&key="+api_key;
response = http.get(api_url.toURL());
// Parse the response to extract the street address
data = json.parse(response.getContent());
address = data.results[0].formatted_address;
// Store the address in the "Address" field
mp = Map();
mp.put("Address",address);
update = zoho.crm.updateRecord("ARCH_Concept_Ltd",leadId.toLong(),mp);
info mp;
info update;
I'm getting the following error:
Failed to save the function
Syntax error. Expecting executeshellscript task,expression,invokeurl task or 'invokeintegration'. Found '['. Line Number: 11
The error message says it is expecting executeshellscript task,expression,invokeurl task or 'invokeintegration'..
Although it says the error is at the '[' on line 11, that is just where the interpreter finally gave up.
This line: response = http.get(api_url.toURL()); can be replaced with zoho-Deluge's invokeurl command so give that a try.

User's Speed Data at a Specific Time

What should I do to get the user's speed data at a specific time? Is it enough for me to subscribe to the recordClient API?
You can try to basic history session from Google Fit Git repository.
https://github.com/googlearchive/android-fit/blob/master/BasicHistorySessions/app/src/main/java/com/google/android/gms/fit/samples/basichistorysessions/MainActivity.java
// Build a session read request
SessionReadRequest readRequest = new SessionReadRequest.Builder()
.setTimeInterval(startTime, endTime, TimeUnit.MILLISECONDS)
.read(DataType.TYPE_SPEED)
.setSessionName(SAMPLE_SESSION_NAME)
.build();
// Invoke the Sessions API to fetch the session with the query and wait for the result
// of the read request.
SessionReadResult sessionReadResult =
Fitness.SessionsApi.readSession(mClient, readRequest)
.await(1, TimeUnit.MINUTES);
// Get a list of the sessions that match the criteria to check the result.
Log.i(TAG, "Session read was successful. Number of returned sessions is: "
+ sessionReadResult.getSessions().size());
for (Session session : sessionReadResult.getSessions()) {
// Process the session
dumpSession(session);
// Process the data sets for this session
List<DataSet> dataSets = sessionReadResult.getDataSet(session);
for (DataSet dataSet : dataSets) {
dumpDataSet(dataSet);
}
}
For more inforation on session just check this link
https://developers.google.com/fit/android/using-sessions#read_fitness_data_using_sessions

Username in WebTokenRequestResult is empty

in a Windows 10 UWP I try use WebAuthenticationCoreManager.RequestTokenAsync to get the result from a login with a Microsoft account.
I get a WebTokenRequestResult with Success. ResponseData[0] contains a WebAccount with an ID - but the UserName is empty.
The scope of the call is wl.basic - so I should get a lot of information...
I'm not sure how to retrieve extra information - and for the current test the Username would be OK.
I checked out the universal samples - and there I found a snippet which tries to do what I'm trying - an output of webTokenRequestResult.ResponseData[0].WebAccount.UserName.
By the way - the example output is also empty.
Is this a bug - or what do I (and the MS in the samples) have to do to get the users profile data (or at least the Username)?
According to the documentation (https://learn.microsoft.com/en-us/windows/uwp/security/web-account-manager), you have to make a specific REST API call to retrieve it:
var restApi = new Uri(#"https://apis.live.net/v5.0/me?access_token=" + result.ResponseData[0].Token);
using (var client = new HttpClient())
{
var infoResult = await client.GetAsync(restApi);
string content = await infoResult.Content.ReadAsStringAsync();
var jsonObject = JsonObject.Parse(content);
string id = jsonObject["id"].GetString();
string name = jsonObject["name"].GetString();
}
As to why the WebAccount property doesn't get set... shrugs
And FYI, the "id" returned here is entirely different from the WebAccount.Id property returned with the authentication request.

EWS Managed - Is it possible to get full "From" details using "FindItems"?

I'm using the Exchange Web Services Managed API to search a message folder using FindItems. The code I'm using is this:
var search = new SearchFilter.ContainsSubstring(
ItemSchema.Subject,
"subject I want");
ItemView searchView = new ItemView(9999);
searchView.PropertySet = new PropertySet(
BasePropertySet.IdOnly,
ItemSchema.Subject,
ItemSchema.DateTimeReceived,
EmailMessageSchema.From);
searchView.OrderBy.Add(
ItemSchema.DateTimeReceived,
SortDirection.Descending);
searchView.Traversal = ItemTraversal.Shallow;
var searchResults = _service.FindItems(
folderToSearch.Id,
search,
searchView);
The search works fine, and the properties I've specified in the searchView.PropertySet do get returned. The problem is that it doesn't return all of the details of From.
I iterate searchResults, and cast the items to type EmailMessage or PostItem as appropriate, to access the From property, which returns an EmailAddress object. On that object, the Name property is set, but Address is null.
If I then bind the item, like:
var boundItem = Item.Bind(_service, message.Id);
var boundItemEmail = boundItem as EmailMessage;
Then boundItemEmail.From.Address is not null, it returns the senders email address.
The trouble is, binding a message can be a rather time-consuming process, compared to the much faster FindItems operation.
You should be able to use the LoadPropertiesForItems method to get the From property, it's faster than binding to individual messages.

Limit the fields return by twitter api Json format

I have read the documentation provided by the twitter, but it seem I haven't found how to limit the fields returned in my script.
here's my script
$url = 'http://api.twitter.com/1/statuses/home_timeline.json';
$params['count'] = 1;
$params['oauth_version'] = '1.0';
$params['oauth_nonce'] = mt_rand();
$params['oauth_timestamp'] = time();
$params['oauth_consumer_key'] = $consumer_key;
$params['oauth_token'] = $access_token;
what params should I add?
There are few, if any, field (de)selectors for the Twitter API. Some timeline and tweet delivery methods support trim_user=true as a parameter to remove the fully embedded user objects but that's pretty much the only way to obtain less data per individual tweet object.