I have been trying to build a kind of Hello World project using Google + SignIn. I followed the tutorial at https://developers.google.com/+/web/signin/, with my (excerpted) code being:
...
<script>
function signinCallback(authResult) {
//location.reload();
//var x = 0
//while(x=0){
if (authResult['access_token']) {
// Successfully authorized
// Hide the sign-in button now that the user is authorized, for example:
document.getElementById('signinButton').setAttribute('style', 'display: none');
//document.getElementById("secret").innerHTML = ("<p>Non-Conspicuous Link to Super Secret Page</p>");
//alert("IT WORKED");
document.getElementById("secret").innerHTML=("Non-Conspicuous Link to Super Secret Page");
document.getElementById("game").innerHTML=("Non-Conspicuous Link to Super Secret Game Page");
document.getElementById('refresh').setAttribute('style', 'display: none');
//alert("Please Refresh");
} else if (authResult['error']) {
// There was an error.
// Possible error codes:
// "access_denied" - User denied access to your app
// "immediate_failed" - Could not automatically log in the user
console.log('AuthERROR: ' + authResult['error']);
//alert("ERROR: A team of poorly trained robots has been dispatched to handle the situation. If they arive, tell them '" + authResult['error'] + "'");
}
}
</script>
...
<span id="signinButton">
<span
class="g-signin"
data-callback="signinCallback"
data-clientid="CLIENT ID"
data-cookiepolicy="single_host_origin"
data-requestvisibleactions="http://schemas.google.com/AddActivity"
data-scope="https://www.googleapis.com/auth/plus.login"
data-width="wide"
data-theme="light">
</span>
...
<p id="secret"></p>
...
When I run the code in Google Chrome (Version 29.0.1547.18 dev-m), I get this error:
Blocked a frame with origin "https://accounts.google.com" from accessing a frame with origin "https://apis.google.com". Protocols, domains, and ports must match.
The code in my signinCallback function is called on the page's first load, but doesn't run when the button is used for sign in. The code isn't executed until the page is reloaded.
However, this issue does not occur in Firefox, so it seems to be an error isolated to Chrome. I have not yet tested any other browsers.
Is there anyway to solve this issue?
Thanks!
I was adapting the java hybrid server-side flow quick-start app and having the "blocked frame" error even when using https. I found that the error was triggered by this block of javascript client-side code (within the onSignInCallback function):
for (var field in authResult) {
$('#authResult').append(' ' + field + ': ' +
authResult[field] + '<br/>');
}
The code above is part of the quick-start app and is there for education purposes only. The error occurs when enumerating or getting a certain field within the authResult object. Removing the above code (or surrounding it with a try-catch block) solved the problem.
Turns out that the reason that my button wasn't authenticating without a refresh was beacuse I forgot to close my <script> on my server, even though it was closed in the code in my question.
For the error it does seem like you can ignore it (thanks #Ismael ToƩ).
Related
I am trying to combine Github Pages with Google Apps Script so I can have Server Side Scripting with Github Pages. I try to connect to the Google Script web app using:
<script src="https://script.google.com/macros/s/NO_LINK_FOR_YOU/dev">
</script>
(I need that /dev there, google script says nothing was returned when I don't use it.)
That is supposed to (and does) return:
return ContentService.createTextOutput("window.onload = function(){document.getElementById(\"request\").innerHTML = \"Generated: " + generateRandomNumber(10, 42) + "\";}");
Which outputs this:
window.onload = function(){document.getElementById("request").innerHTML = "Generated: 28";}
(Of course, it would not always be 28.)
When I load this into the browser, it does nothing. I looked in inspect element and it says that it's returning the code 302 (Temporarily Moved). This is usually used for redirects, and content service always makes the browser redirect "for security reasons", so this is expected.
But how can I get the browser to follow that redirect and get the script from there? Can I even do that?
In this case, a mimetype error occurs, since mimetype is not set. So please add setMimeType() as follows.
return ContentService
.createTextOutput("window.onload = function(){document.getElementById(\"request\").innerHTML = \"Generated: " + generateRandomNumber(10, 42) + "\";}")
.setMimeType(ContentService.MimeType.JAVASCRIPT);
I recently added an SSL certificate to my website and since then some of the jquery functions are no longer working. Specifically jquery.get
Example:
function getBfeForm() {
jQuery.get('/wp-admin/admin.php/?page=booking.multiuser.5.3/wpdev-booking.phpwpdev-booking-resources&tab=availability&wpdev_edit_avalaibility=<?php echo key($_REQUEST['avail']); ?>/', function(data) {
jQuery('[name="avail['+<?php echo key($_REQUEST['avail']); ?>+']"]').removeClass('spinner').val('Edit Availability');
if (data) {
jQuery('#availHolder .holder').html(jQuery(data).find('.inside'));
jQuery('#availHolder .holder').prepend('<div id="popHeader"><a title="Close" class="fancybox-item fancybox-close" href="javascript:;">Close</a></div>');
jQuery('#availHolder').hide();
jQuery('#availHolder').appendTo(jQuery('[data-resource="<?php echo key($_REQUEST['avail']); ?>"]').find('tr.clean td'));
jQuery('#availHolder').slideDown(500);
}
});
}
This function works fine with http but when SSL is activated and https used the function no longer calls the file. I have seen other comments on here saying the lack of trailing slashes is the issue, but I believe I have added trailing slashes correctly now and it still doesn't work.
Any help would be greatly appreciated.
UPDATE: I added alert("Data: " + data + "\nStatus: " + status); to the function to see what data was actually being served. It appears the wordpress log in page is being called rather than the file specified in the function. I have tested this on a duplicate site without SSL and it calls the correct file. Does this mean the SSL is not allowing a link to wp-admin files?
If you are using windows and have a local certificate installed in IIS then try access the site with fully qualified name of the computer
[computer_name].[domain_name]
For example: [ox-pchris11].[companyname.com] where ox-pchris11 is the computer name and companyname.com is the domain name.
if you access the site as localhost it will show a error page which will ask permission to continue.
I found the problem and posting the answer here for anyone else who is implementing an SSL certificate. The issue was the custom login page we have. We are using the wp_signon function and we had $user_verify = wp_signon( $login_data, false );. This should be $user_verify = wp_signon( $login_data, true ); - setting the value to 'true' creates a secure cookie. If the cookie is not secure, each time a user tries to access wp-admin files they are logged out and required to log in again.
For details check the wordpress codex for wp_signon.
I'm trying to implement a Google+ Signin on a website, following instructions from here for a hybrid login system. I prefer to have my own button for login, so I chose to implement the G+ signin through plain JavaScript method gapi.auth.signIn, following instructions from here.
Here's the button I have on my main page that initiates the login -
<a id="gplogin" href="#">
<img src="{% static 'images/gp.png' %}"/>
</a>
Here's the corresponding JQuery piece that picks up the click, this is running fine too -
$('#gplogin').click(
function() {
GPLogin();
return false;
});
Here's the GPLogin() part, which is probably where it's throwing Javascript exception -
function GPLogin() {
// Define all the login params
var additionalParams = {
'clientid' : 'xxxxxxxx.apps.googleusercontent.com',
'scope' : 'https://www.googleapis.com/auth/plus.login',
'redirecturi' : 'postmessage',
'requestvisibleactions' : 'http://schema.org/AddAction',
'cookiepolicy' : 'single_host_origin',
'accesstype' : 'offline',
// 'approvalprompt' : 'force',
'callback': gpSigninCallback
};
console.log('Logging in to Google Plus with additional params - ');
for(var param in additionalParams)
console.log(param + " : " + additionalParams[param])
gapi.auth.signIn(additionalParams);
}
Here's my gpSigninCallback function which is never getting called, due to exception thrown when I click the 'gplogin' link
function gpSigninCallback(authResult) {
console.log("GP Signin response " + authResult);
for(var res in authResult)
console.log(res + " : " + authResult[res]) }
The exception that is being thrown when I click on the gplogin link is
Uncaught TypeError: Cannot convert object to primitive value at cb=gapi.loaded_0:41
as observed in Chrome.
The user selection popup comes up as expected and I can select the user, but nothing happens anywhere after that. I'm pretty sure it's a small thing I'm overlooking somewhere, but I cannot find it myself. Any help would be appreciated. Thank you !
After quite a bit of searching around, I narrowed it down to simple Javascript error on my part. I started by commenting all the debug statements and printing the objects as-is. That is where I discovered that my callback function was getting an object for authResult[res] in one of the iterations and since I was trying to concatenate it to a String, a TypeError was being thrown.
The Google Plus Login flow was fine all the time, with my JS being the issue. It worked in GPLogin() when trying to log additionalParams[param] because they're all strings and have no problems concatenating with Strings.
I'm trying to experiment with the new javascript integration features of oracle forms 11g.
My current configuration:
Forms 11.1.2.2.0
Weblogic 10.3.6.0
JRE 1.7u55
Windows 7 x64
I installed the demo at http://www.oracle.com/webfolder/technetwork/tutorials/obe/forms/11g/jsinteg/formsjsinteg/setup.htm
This is only working from FORMS to Javascript but not the other way. i.e Javascript to FORMS.
I thought all the additional Javascripts et al in it is making it difficult for me to know what's happening so I created a simpler html page with a textbox, a button and an anchor for onclick along with the applet in iFrame.
Again the code is working from FORMS to javascript but not the other way.
This line is not working:
window.frames['forms_iframe'].contentDocument.document.forms_applet.raiseEvent(event, payload);
UPDATE:
I changed it so the applet and all the testing code is placed in one html. and added some try catch code to my calls.
changed my call to:
function frmEvent (event, payload) {
alert(event+", "+ payload);
event = "PUSH";
try {
document.forms_applet.raiseEvent(event, payload);
}
catch(err) {
var txt = "There was an error on this page.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
}
Now I get in IE
liveconnect call for applet id 1 is not allowed in this jvm instance
in chrome, it says:
Error calling method on NPObject
I think the whole problem is with this liveconnect changes to java runtime... wondering what else to do to solve this issue now.
Lower the Java security setting from High (only authorized Java script can be run) to Medium (Prompt before unauthorized Java script), user will receive a prompt and then the worksheet can be opened just
fine. It's due to higher security requirement with JRE 7u45
https://blogs.oracle.com/java-platform-group/entry/updated_security_baseline_7u45_impacts
I have a page on which mysterious JavaScript errors keep popping up. They appear to be coming from the application we use and do not own the source for. I'm working on a real solution to this issue, but we have a demo tomorrow and I was wondering if there is a way to just suppress JS errors page wide (like wrapping ALL the javascript components in a giant try catch).
You could add a handler to the window.onerror event. In this case, all the errors that occur inside the window will be redirected to the handler of this event. (I did test this in Firefox and it worked, but I was having trouble with it in Chrome - my Chrome installation is pretty messed up, so that could be the problem, but there are Chromium bugs filed that relate to this issue: bug #7771 and bug #8939)
window.onerror = function (msg, url, line) {
alert("Error on line " + line + " in " + url + ":\n" + msg);
// return true to prevent browser from displaying error
return true;
}