Oauth2 question again

Hello, still haven’t gave up on this, i think i reached a bit of understanding but google block the login coz the launch.playcanvas.com can’t be added to allowed domains coz it’s a second level address. Anyone has a way to go around it?

Im not sure if you can go around it, if google blocks it

Hi @ayrin, in case it’s of help, if you are unable to use a login provider with a playcanvas.com / playcanv.as based domain because you don’t own it (and can’t authorise it) then a solution is to iframe the PlayCanvas app on a website that you host on your own domain name.

So you do the oauth handshake in the parent website that is hosted in your domain name, and communicate with the PlayCanvas app with window.postMessage.


Hi @Leonidas with playcanv.as there is no problem coz it’s a first level domain, but i can’t test it without publishing. Beside i was trying to test the published version of login page but it doesn’t work coz the 2d button is not showed. You can see it launching the login from https://playcanvas.com/editor/scene/992647 and from https://playcanv.as/p/hTLgqIre/

1 Like

Not sure what the fix would be in this case, sorry, most likely something to check with Google.

No @Leonidas what it disappear is the 2d button made in playcanvas…don’t get why.

That shouldn’t be related with that, unless you code that is responsible of showing/enabling that button doesn’t execute because of an error you are getting due to oauth.

Solved the button trouble and made some progress, now i have an error in line 60 is not a function
but i have the function

Oauth2.prototype.setSigninStatus =function() {
    var user = GoogleAuth.currentUser.get();
    var isAuthorized = user.hasGrantedScopes(SCOPE);
    if (isAuthorized) {
      $('#sign-in-or-out-button').html('Sign out');
      $('#revoke-access-button').css('display', 'inline-block');
      $('#auth-status').html('You are currently signed in and have granted ' +
          'access to this app.');
    } else {
      $('#sign-in-or-out-button').html('Sign In/Authorize');
      $('#revoke-access-button').css('display', 'none');
      $('#auth-status').html('You have not authorized this app or you are ' +
          'signed out.');

Hi @ayrin,

I just copied your script from the project, and I noticed that line 60 in your script is still defined as :


Are you sure that the script is saved with the self variable on that line?


Hi @eproasim i hae tried with both this. and self. but no luck either

found the problem this. is no more the same this. value now looking for a solution

this is what happen to this…any clue why?
this change

are you looking for an auth2 error or this. error now?

I’ve forked the project, changed this back to self in the callback.

After doing that, self was referring to the scriptType object as expected.

There’s then an error where SCOPE was not defined, that’s because in the initialize function, it was defined as a local variable. I’ve changed it to this.SCOPE on both the line error and the initialize function.

Now there are no errors AFAIK tell.

Was this your original issue?

Hello @yaustar, i have made the changes and it gives no errors, still not doing what it should but it’s good enough as result, i will work on the code a bit more.
No I don’t have the google message but i think that can be overcome with the advanced options. Anyway i will look into that message too.
Thanks a lot.

Got that alert as well, overcame with the advanced options and got a new error…it feels a bit stressing lol

Now i can sign in but i can’t sign out lol

API keys, client IDs and hashes are considered secret, and you don’t want to post them in the open like this. Consider removing the screenshot.

1 Like

Ok…i’m fighting again with this. changing i have made const self=this; but both self and this changes. I am trying anything but those keep changing…before or later…and i start to feel frustrated…should i use Object.freeze?

self shouldn’t change as it’s scoped. Are you sure it’s changing?