amp-list component error in amp for email - email

I am new to AMP for Email and I am trying it out now! I am using the amp-list component in my email body to fetch the remote server json content. But I am getting the below js error when i checked in my browser console. Also in my Gmail inbox in the mail I received its blank.
Uncaught (in promise) Error: Class$obf_1013: [https://dynamicmail-pa.googleapis.com/v2/xhrs:proxy?alt=protojson] ti: Unsupported HTTP status: 400: Class$obf_1011: [object Object]
template-impl.js:241 Error proxying amp-list templates: Request viewerRenderTemplate failed: Error: Class$obf_1013: [https://dynamicmail-pa.googleapis.com/v2/xhrs:proxy?alt=protojson] ti: Unsupported HTTP status: 400: Class$obf_1011: [object Object]​​​

Here are the correct headers to send for AMP to work in gmail:
https://developers.google.com/gmail/ampemail/security-requirements?hl=ur#gmail
Access-Control-Allow-Origin: https://mail.google.com
AMP-Access-Control-Allow-Source-Origin: <your sender email address>
Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin

We need to set the Content-Type & Access Control headers for CORS request like -
header("Content-type: application/json");
header("Access-Control-Allow-Credentials: true");
header('Access-Control-Allow-Origin: *');

Related

Sanic CORS Exception handler

I have tried to use Sanic_CORS in exception handler like error 404,
but I received CORS error
Access to XMLHttpRequest at 'http://backend:port/endpoint' from origin 'http://react_app:port' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
There are no problems with valid endpoints.
My error handler
#app.exception(NotFound)
async def ignore_404s(request, exception):
return response.json({'message': "Oops, server error"},
status=404)
How can I implement Sanic_CORS for error handlers? Any ideas?
One option would be to just add the header into your response. Albeit, this is not using the sanic-cors package, but you really do not need it here.
#app.exception(NotFound)
async def ignore_404s(request, exception):
return response.json(
{'message': "Oops, server error"},
status=404,
headers={"Access-Control-Allow-Origin": "*"}
)

Ionic issue with HttpClient.post (No 'Access-Control-Allow-Origin' header is present)

Well, I've tried to send a post request from HttpClient class in Ionic3, in the next code fragment I show the function in TypeScript.
constructor(public http: HttpClient, ...){ ... }
loginAndGetUserData(email0, password0): any
{
return this.http.post
(
'http://xxx.a_api/api/login.json',
{
email: email0,
password: password0
},
{
headers:
{
'Access-Control-Allow-Origin':'*',
'Access-Control-Allow-Methods':'POST, GET, OPTIONS, PUT',
'Content-Type':'application/json',
'Accept':'application/json'
}
}
);
}
Then, when I call this method I receive an error with undefined code as response.
ErrorCode: undefined
Http failure response for (unknown url): 0 Unknown Error
Capture image of device
In Android logs, after the function call, I get this message:
08-09 21:16:31.649 19292-19292/io.ionic.starter D/SystemWebChromeClient: http://localhost:8080/: Line 0 : XMLHttpRequest cannot load http://xxx.a_api/api/login.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 405.
08-09 21:16:31.649 19292-19292/io.ionic.starter I/chromium: [INFO:CONSOLE(0)] "XMLHttpRequest cannot load http://xxx.a_api/api/login.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 405.", source: http://localhost:8080/ (0)
And in my PHP code I tried to put 'Access-Control-Allow-Origin:*' in header, but It receive empty data from the client. In some Ionic forum some people say that I have to modify ionic.config.json file putting proxies attribute with path and proxyUrl, but neither It resolve my issue.proxies attribute, in ionic.config.json file, looks like:
"proxies":
[
{
"path": "/api",
"proxyUrl": "http://xxx.a_api/api"
}
]
Well, I don't know what to do, I'm sure that It's a client problem, 'cause the server receive empty data.
Thanks in advance.
This is CORS issue. You will need to handle it on server side. For testing purpose, you can use Allow-Control-Allow-Origin: * plugin from chrome web store. By enabling this plugin your issue will be resolved.

Getting HTTP 400 when requesting access token

I am trying link Actions on Google with a 3rd party service (non-Google). I am using Google Oauth 2.0 Playground to check if I am getting the auth code and the access token. I successfully received the auth code but when requesting the access token I am receiving the following result from the response.
HTTP/1.1 400 Bad Request
Content-length: 16
Content-type: text/plain
WWW-Authenticate
I am not sure when I am doing wrong here. What does WWW-Authenticate mean?
Thanks in advance.

Why can't I wget from this address?

I'm trying to wget from the "Download Now" link on this website but it returns the following error:
$wget https://www.spigotmc.org/resources/supervanish.1331/download?version=46330
--2015-09-27 19:13:53-- https://www.spigotmc.org/resources/supervanish.1331/download?version=46330
Resolving www.spigotmc.org (www.spigotmc.org)... 198.41.204.94, 198.41.205.94, 2400:cb00:2048:1::c629:cd5e, ...
Connecting to www.spigotmc.org (www.spigotmc.org)|198.41.204.94|:443... connected.
HTTP request sent, awaiting response... 503 Service Temporarily Unavailable
2015-09-27 19:13:53 ERROR 503: Service Temporarily Unavailable.
Here is the page:
https://www.spigotmc.org/resources/supervanish.1331
Here is the URL:
https://www.spigotmc.org/resources/supervanish.1331/download?version=46330
You cannot wget because the server returns an error.
If you want to retrieve an error page, perhaps this page will help you.

Dropbox API returning http 500 status instead of http 400 status for a non-existant user in a team

Starting at around 21:00 PM GMT today , when we query for a user which doesn't exist in dropbox team, we are receiving an http 500 status with internal error message. In comparison earlier we use to receive http 400 message with message that user doesn't exist in team.
Has something regressed at dropbox end, or is this change intentional and hence we should consider http 500 internal error as equivalent to user not found?
For example RESPONSE#1 is what we expected as valid behavior , while RESPONSE#2 is what we are receiving currently
RESPONSE#1
Resource: https://api.dropbox.com/1/idm/get_profile?email=dummy#authentication.test
Operation: GET
Headers: Authorization: Bearer XXX
Content Type:
Data:
%% Time: 08/28/2014 17:06:51 GMT
Message: The remote server returned an error: (400) Bad Request. Web Response: {"error": "User not on this team"} ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
RESPONSE#2
Resource: https://api.dropbox.com/1/idm/get_profile?email=dummy#authentication.test
Operation: GET
Headers: Authorization: Bearer XXX
Content Type:
Data:
Time: 08/28/2014 22:40:29
(500) Internal Server Error. Web Response: {"error": "Internal Server Error"} ---> System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
Thanks
Somesh