Google+'s Signin APis [AngularJS]: Refused to display 'X-Frame-Options' to 'SAMEORIGIN' - angularjs

I've had a look to several similar problems on SO on this problems but I didn't find one which solves mine.
I'm following this tutorial to implement Google+'s Sign-in in my web application: https://blog.codecentric.de/en/2014/06/angularjs-google-sign-integration/
gapi is loaded correctly.
In my controller I have the following code:
gapi.signin.render('signInButton',
{
'callback': $scope.signInCallback, // Function handling the callback.
'clientid': '[MY_CLIENT_ID].apps.googleusercontent.com',
'requestvisibleactions': 'http://schemas.google.com/AddActivity',
'cookiepolicy': 'single_host_origin'
}
);
where
MY_CLIENT_ID is of course replaced by my actual client ID got from Google Dashboard.
I'm working on localhost:85 and "Javascript origin" is set exactly to http://localhost:85/
The error I'm getting is:
Refused to display ... in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'
NOTE: this error appears only sometimes. I don't understand why (the user interaction doesn't change, though).

Related

PrintJS getting blocked a frame with origin issue

Hi My Main Application url is http:localhost:4000. It internally render iframe app which is http:localhost:4000/contentApp/index.html (with sandbox parameter as sandbox="allow-scripts allow-popups allow-modals allow-forms allowdownloads allow-same-origin") and its in React application.
PrintJS package, using 1.0 version and it makes call to printJS(URL)
//URL, blob:http:localhost:4000/[guid value]
It gets an error at below piece of code within printjs library.
print.js:
try{
iframeElement.focus(); // iframeElement = iframe#printJS { src: blob:http://localhost:4000/a33334343-33434-343434-343434adf', src: '', name: '', sandbox: DOMTockenList(0..)
...
// other browsers
iframeElement.contentWindow.print(); // throw CORS error at here.
} catch(error){ params.onError(error);}
finally {
(o,_function.cleanup)(params);
}
}
above, iframeElement.contentWindow.print() getting an error out with below error CORS:
Uncaught DOMException: Blocked a frame with origin "http://localhost:4000" frame accessing a cross-origin frame.
at performPrint (webpack-internal:///./node_modules/print-js/dist/print.js:898:35)
at HTMLIframeElement.iframeElement.onload (webpack-internal:///./node_modules/print-js/dist/print.js:852:11)
..
When I remove sandbox then it worked. However, I can not remove sandbox as its structure of application.
Is there any way to fix this CORS issue. Like adding some parameter in "iframe sandbox attribute" OR any option at 'printjs' to fix this issue ?
Appreciate for the help.
PrintJS, internally call iframeElement.contentWindow.print(); , I don't have control to do postMessage as its printJS package part. Though, I have control over localhost:4000/contentApp , sandbox attribute.
(Also, it looks like issue created at, "http://localhost:4000" != "BLOB:http://localhost:4000/GUIDvalue" , (which looks weird as, both are pointing to same origin".)

CodenameOne - how to catch HTTP 404 error using Terse REST API

How can I catch an HTTP 404 error using the Terse REST API in CodenameOne? At the moment the default error handler gets this but I would like to display my own message instead. The code I am using is fine if the accountNo exists and I can deal with the resulting JSON, but if not I get the standard error handler displaying the 404 error:
Response<Map> jsonData = Rest.get( URL + "lookup").
jsonContent().
queryParam("account",accountNo).
getAsJsonMap();
This seems to be a mistake in that version of the method. It should fail silently without a UI Dialog. We'll fix it for the next update.
Notice that jsonData should have the error response code within it as jsonData.getResponseCode().

MEAN RESTful application error handling server crashes

I've just followed a tutorial for creating a simple RESTful api using the MEAN stack from the heroku webpage. What I did was just cloning the repo that contains the sample code, added my mongodb_uri from mLab and then run the app locally (npm start).
It works perfectly, but when I try to make an invalid entry (not providing name and last name to a contact) the express server crashes and the entry is made on my database (which is inconsistent).
I've opened an issue on the github repo but I got no answers, I think that there must be something wrong with the error handling but I don't know what it might be.
Here it is what I get when the server crashes:
ERROR: Invalid user input
/Users/nanop/Desktop/mean-contactlist/node_modules/mongodb/lib/utils.js:98
process.nextTick(function() { throw err; });
^
Error: Can't set headers after they are sent.
at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:344:11)
at ServerResponse.header (/Users/nanop/Desktop/mean-contactlist/node_modules/express/lib/response.js:719:10)
at ServerResponse.send (/Users/nanop/Desktop/mean-contactlist/node_modules/express/lib/response.js:164:12)
at ServerResponse.json (/Users/nanop/Desktop/mean-contactlist/node_modules/express/lib/response.js:250:15)
at /Users/nanop/Desktop/mean-contactlist/server.js:72:23
at /Users/nanop/Desktop/mean-contactlist/node_modules/mongodb/lib/collection.js:421:18
at handleCallback (/Users/nanop/Desktop/mean-contactlist/node_modules/mongodb/lib/utils.js:96:12)
at /Users/nanop/Desktop/mean-contactlist/node_modules/mongodb/lib/collection.js:726:5
at /Users/nanop/Desktop/mean-contactlist/node_modules/mongodb-core/lib/connection/pool.js:428:18
at nextTickCallbackWith0Args (node.js:433:9)
And finally this is the handleError method defined which I think it's ok:
function handleError(res, reason, message, code) {
console.log("ERROR: " + reason);
res.status(code || 500).json({"error": message});
}
This is the repo I refer to: https://github.com/chrisckchang/mean-contactlist

Error in requesting track for url for SPTTrack object

I am trying to get SPTTrack object from url using Spotify iOS SKD v10beta.
Somehow, it returns an error, like :
Error Domain=com.spotify.ios-sdk Code=102 "No registered class for type 'artist'" UserInfo=0x7a644700 {NSLocalizedDescription=No registered class for type 'artist'}
Strange thing, that it has worked previously. I have found similar problem in getting the user.
What this error is related to? I have removed/added,linked spotify framework multiple times.
Ideas?
Error occurred because ObjC was not present at Other Linker Flags in frameworks/libraries/targets/project.

Difference between "drive.metadata.readonly" and "drive.readonly.metadata"

I want to ask what is the difference between DriveScopes.DRIVE_METADATA_READONLY and https://www.googleapis.com/auth/drive.readonly.metadata? In other words, what is the difference between
these two forms:
https://www.googleapis.com/auth/drive.metadata.readonly //DriveScopes.DRIVE_METADATA_READONLY
https://www.googleapis.com/auth/drive.readonly.metadata
When I was using service account for working with Drive API it takes me a long time to figure out, why my app was throwing unauthorized exception:
Uncaught exception from servlet
com.google.api.client.auth.oauth2.TokenResponseException: 403
{
"error" : "access_denied",
"error_description" : "Requested client not authorized."
}
The String constant DriveScopes.DRIVE_METADATA_READONLY was causing the exception. In which context should I use this constant?
That's clearly a mistake in the Java API client.
The API documentation states that the correct scope is :
https://www.googleapis.com/auth/drive.readonly.metadata
Whereas when you look at the latest javadoc (at the time of this answer), you get :
https://www.googleapis.com/auth/drive.metadata.readonly
You should ignore the DriveScopes constant and create your own constant, while the Google Drive team fixes this.

Resources