hello.js icon indicating copy to clipboard operation
hello.js copied to clipboard

Chrome Error

Open georg-schwarz opened this issue 7 years ago • 6 comments

Hi,

I am using HELLOJS with the following configuration:

const GOOGLE_SCOPES = 'https://www.googleapis.com/auth/userinfo.profile, https://www.googleapis.com/auth/userinfo.email'

hello.init({
      google: GOOGLE_CLIENT_ID
});

hello(_this.network.google).login({
          display: 'popup',
          response_type: 'token id_token',
          scope: GOOGLE_SCOPES,
          force: true // let user choose which account he wants to login with
}).then(function() { .....

The error happens in the login function, where str is parsed into an Object:

// Login
	// Using the endpoint
	// @param network stringify       name to connect to
	// @param options object    (optional)  {display mode, is either none|popup(default)|page, scope: email,birthday,publish, .. }
	// @param callback  function  (optional)  fired on signin
	login: function() {
         .......
                // Create a global listener to capture events triggered out of scope
		var callbackId = utils.globalEvent(function(str) {

			// The responseHandler returns a string, lets save this locally
			var obj;

			if (str) {
				obj = JSON.parse(str);
			}

I debugged and found out, that in Chrome str is already an Object. Because of that, JSON.parse() throws an exception. However in Firefox, str is a String and so no exception!

Also note, that this only happens the first time trying to sign-in after loading the page.

Any ideas why this happens? It has already worked, but somehow doesn't anymore... Could it be related to a failed CORS thing in the popup? (doesn't close after login)

Thank's in advance.

Greetings, Georg Schwarz

georg-schwarz avatar Jan 12 '18 13:01 georg-schwarz

Seems to be caused by the same origin as in issue #473

georg-schwarz avatar Jan 19 '18 10:01 georg-schwarz

The Portfolium team is running into this as well... We've tested on every major browser, and they all work besides Chrome.

It only happens when you have to enter a new email that your browser doesn't already have a Google account linked up for (using an Incognito window is the easiest way to test).

danielzev avatar Feb 03 '18 07:02 danielzev

@MrSwitch any feedback on this one?

danielzev avatar Feb 13 '18 22:02 danielzev

@SchwarzGeorg @danielzev I can't reproduce this.

I've updated the Google Login example https://adodson.com/hello.js/demos/google.html can you recreate it on that page?

Also can you include this object which should be a string. Please obfusicate any tokens. Thanks

MrSwitch avatar Feb 17 '18 16:02 MrSwitch

Somehow not reproducable any more, also in my own application. Maybe a Chrome Update fixed that!

georg-schwarz avatar Mar 26 '18 09:03 georg-schwarz

yeaaaaaaa!!!!! thanks for letting us know @SchwarzGeorg Looks good on Portfolium.com too

danielzev avatar Mar 26 '18 22:03 danielzev