Profile image is not displayed (error 403) - google-api

I'm using Google API (People) list and from returned JSON, I try to use image listed on "url" field:
"photos": [
{
"url": "https://lh3.googleusercontent.com/cm/AATWAfu9TeDbEEC2VEJqYuO1eGr1F7qRpGSvgKlsjMhny8UWSAB_STRGbHQYvwIQzgrp=s100",
"default": true,
"metadata": {
"source": {
"type": "CONTACT",
"id": "4da7eb9a8d9a19e5"
},
"primary": true
}
}
]
Problem is - not all images are displayed, like you can see here:
https://i.postimg.cc/BvPJLyD5/image-2023-01-11-172253699.png.
On console, I see error 403.
When I manually copy link (from "url" link above) and open it in browser, image is normally displayed. Also, when I reload page few times manually, some images are displayed and some other not (randomly).
Is there any solution for this?

It is related to logged status.
If I'm logged into Gmail or Drive, images are randomly displayed.
If I logout from Gmail and use API again, all images are always displayed. It is same for Google Drive, as you can see here: https://issuetracker.google.com/issues/229184403?pli=1

Related

How to fix messages_tab_disabled error in Slack's chat.postMessage API?

I'm trying to post a direct message to a specific Slack user. I'm using chat.postMethod method. The below example works fine when channel is a channel ID. But when I change it to a users ID (as described in this documentation), I get back a messages_tab_disabled error.
POST URL: https://slack.com/api/chat.postMessage
{
"channel": "U02F7EXXXXX",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hello"
}
}
]
}
I get back...
{
"ok": false,
"error": "messages_tab_disabled"
}
I can't find much on this other than a description on the documentation page that just says "Messages tab for the app is disabled.".
Where is it and how do I enable it?
I stumbled upon how to fix this when I was poking around settings for my app. In case this helps anyone else in the future...
In your apps configuration page, under Features > App Home, scroll down to the Show Tabs section and there is an option called Messages Tab that is off by default. I turned it on and now I can message users directly.

How to access Cypress data in the console

Below is a screen shot of Cypress 6.8 runner. I am interested in accessing the data printed in the console shown on the right.
In order to see this information within the browser window where tests are executed, you would open the developer tools and click a row. In the example, I had clicked row 8 which is shown by the purple pin and tooltip stating that "Printed output to your console".
Is it possible to programmatically access to this same information printed in the console? For example, could I get access to the command, applied to and any other information that might be logged. My understanding is this information only appears when clicking the row.
I would like to access this information using a custom plugin. Can you please provide insight into how this might be possible? I've been experimenting with the plugins/index.js module exports which provides access to on. But, at this time I don't have any meaningful code to share. I'm in the learning stage trying to determine if its feasible to access this information. Thanks.
At the top of your spec or in cypress/support/index.js you can add an event listener which listens for log:added, ref Catalog of Events.
Cypress.on('log:added', (logObject) => console.log(logObject))
This provides your callback a stream of the "log attributes" objects in the first parameter, which have a console.props property, which is what is printed when you click a line in the LHS Cypress log.
{
"message": "http://example.com/",
"timeout": 60000,
"name": "visit",
"type": "parent",
"event": false,
"id": 3,
"state": "passed",
"instrument": "command",
"url": "http://example.com/",
"hookId": "r2",
"testId": "r2",
"testCurrentRetry": 0,
"viewportWidth": 1000,
"viewportHeight": 660,
"wallClockStartedAt": "2021-03-20T03:12:21.490Z",
"chainerId": "chainer4",
"consoleProps": {
"Command": "visit",
"Resolved Url": "http://example.com/",
"Redirects": [],
"Cookies Set": []
},
"renderProps": {},
"totalTime": 218,
"snapshots": [
{
"htmlAttrs": {},
"body": {}
}
],
"ended": true
}

AMP: <amp-analytics> occasionally does not register click event on Firefox

For our AMP pages we use <amp-analytics> to track outclicks to web shops. This works fine in most browsers, but in Firefox it seems like these outclicks get registered only half of the time (or even less).
I did some research, and in the console I can see that the request (https://www.google-analytics.com/r/collect?...) is not made in the occasions that we do not see any click.
This is our JSON for registering the outclick. When the user clicks on an element with the .buy-link class, it should register the outclick in Google Analytics.
<script type="application/json">
{
"vars" : {
"gtag_id": "UA-XXXXXXX",
"config" : {
"UA-XXXXXXX": { "groups": "default" }
}
},
"triggers": {
"button": {
"selector": ".buy-link",
"on": "click",
"vars": {
"event_name": "NL",
"event_category": "outclick",
"method": "Google",
"event_label" : "${eventLabel}"
}
}
}
}
</script>
The event-label's value is the name of the store that was clicked on. The data for this retrieved from the HTML element that was clicked on:
<a class="buy-link" data-vars-event-label="Store name" href="https://example.com">...</a>
The data-vars-event-label attribute contains the value for the event_label.
Why do the click events get registered only occasionally? Is there maybe something that clashes between AMP and Firefox? I hope someone can answer me.

IE11 Can't reach this page, but the page is valid and accessible

I have a bit of a bizarre problem happening in IE11. I'm running DataTables with server-side processing so I had to create a custom button for exporting the full data set, since the default buttons only export the visible data set.
Here's the Yajra DataTables for Laravel configuration for one of my buttons:
'buttons' => [
['extend' => 'csv',
'text' => '<i class="fa fa-file-excel-o"></i> CSV',
'action' => 'function(e,dt,node,config){
var data=$.extend(
true,
dt.context[0].oSavedState,
{
columns:dt.context[0].aoColumns.map(function(col){
return {"data":col.data}
})
})
window.location.href = window.location.href +
"?action=csv&" +
$.param(data);
}'
],
...
The button works fine, it basically compiles a list of the columns and filters and sends the user to a Laravel route that handles the action=csv request and generates an Excel download that triggers automatically in Chrome and Firefox.
In IE11, however, the browser redirects to the Excel download route but throws up a "Can’t reach this page" error message. I can see in the address bar that the URL is correct, and what's odd is that if I just hit Refresh in the browser, the CSV download is triggered and I am given the option to save.
This happens every time I click the download link. What might cause IE11 to think the page can't be reached, when it can?
I tried looking at the request/response headers in network tools and everything seems to be just fine. Any ideas?
Also, I tried rewriting my window.location logic to create a hyperlink element, attach it to the DOM, trigger a click, and it still yields the same thing.
More Information
I tried a few other things and was able to eject the download process at any point in the code up until final response to the browser. The browser responds with a 200 status code, when I look at the Network Tab and view the Response Body, I can see my CSV content right there with appropriate Content Disposition, Content Length headers. The Content-Type header is text/plain, but changing it to text/csv didn't solve the problem.
If the IE's Network Tab renders everything correctly, why might IE's browser renderer show a Page Can't Be Displayed error?
Well, I was finally able to resolve the IE/Edge exporting issue and it comes down to query-string length.
The DataTables grid makes a GET request with a whole bunch of properties related to the query (columns that are visible, which filters were applied, etc.).
Sample Request Params:
{
"action": "csv",
"time": "1529689896632",
"start": "0",
"length": "10",
"order": [
["2","asc"],
["1","asc"]
],
"search": {
"search": "",
"smart": "true",
"regex": "false",
"caseInsensitive": "true"
},
"columns": [
{
"visible": "true",
"search": {
"search": "",
"smart": "true",
"regex": "false",
"caseInsensitive": "false"
},
"data": "programs"
},
// ...
Because there are so many columns, these request params create a very lengthy query-string (in the realm of 3-4000 characters). IE and Edge appear to handle query-strings up to a certain length, as I've noticed some bugs come through where the query-string data was truncated.
I ended up reducing the query-string length by omitting unnecessary and default property values needed for the export. Now IE and Edge both immediately respond with the file download instead of throwing a page not found or other bizarre error.

Google place api - application specific search

I am trying to do application specific places search with google place api. Here is how I am adding a place:
Request:
{
"location": {
"lat": 37.760538,
"lng": -121.900879
},
"accuracy": 50,
"name": "p2p",
"types": ["other"]
}
I get success response as shown below:
Response:
{
"id" : "dfe583b1ac058750cf524f958afc5e82ade455d7",
"place_id" : "qgYvCi0wMDAwMDBhNWE4OWU4NTMzOjgwOGZlZTBhNjI3OjBjNTU1OTU4M2Q2NDI5YmM",
"reference" : "CkQxAAAAsPE72V-jhHUjj6vPy2HdC__2MhAdXanL6mlFBA4bcayRabKyMlfKFiah7U2vkoCj1P_0w9ESFSv5mfDkyufaZhIQTHBHY_jPGRHEE3EmEAGElhoUXTSylMslwHSTK5tYdstW2rOZKbw",
"scope" : "APP",
"status" : "OK"
}
When I search for this place using radar search, I get ZERO_RESULTS.
Request:
https://maps.googleapis.com/maps/api/place/radarsearch/json?key=key&radius=5000&location=37.761926,-121.891856&keyword=p2p
Response:
{
"html_attributions": [ ],
"results": [ ],
"status": "ZERO_RESULTS"
}
Is there something that I am doing the right way? Please help.
Thanks & Regards,
--Rajani
Your scope is "APP". That means you can access it (via PlaceID) from the application that created the entry only. If the location passes Google's moderation process, then it will gain scope "GOOGLE" and be accessible from the general searches.
scope — Indicates the scope of the place_id. The possible values are:
APP: The place ID is recognised by your application only. This is because your
application added the place, and the place has not yet
passed the moderation process.
GOOGLE: The place ID is available to other applications and on Google Maps.
Note: The scope field is included only in Nearby Search results and
Place Details results. You can only retrieve app-scoped places via the
Nearby Search and the Place Details requests. If the scope field is
not present in a response, it is safe to assume the scope is GOOGLE.
See: https://developers.google.com/places/documentation/search

Resources