Single Sign-On

Hello everyone!

I have a system with a back-end and a game. This game has 3 builds: Windows, android and webgl. In Windows and android distros the player should provide login and password but is a requirement that in webgl this login should be avoided bescouse the player already is logged in.

So, as a test, a build this:

in index.html I inserted this code:

<script type="text/javascript">
  function InjectData()
  {
   var qs = getQueryStrings();
   var l = qs["u"];
   var p = qs["p"];
   console.log(qs);
   SendMessage ('LoginFormUI', 'ReceiveLogin', l.concat(':').concat(p));
  }
  function getQueryStrings()
  {
   var queries = {};
   var queryString = document.URL.split('?')[1];
   if ( queryString ){
    queryStrings = queryString.split('&');
    for ( var i = 0; i < queryStrings.length; i++ ){
     hash = queryStrings[i].split('=');
     if ( hash[1] ){
                  queries[hash[0]] = hash[1];
     } else {
                  queries[hash[0]] = true;
     }
    }
      }
      return queries;
  }
</script>

In my login scene I have a gameobject named as LoginFormUI with this script:

    void Start()
    {
        Application.ExternalCall("InjectData", null);
     }

    public void ReceiveLogin(string loginData)
    {
        var data = loginData.Split(':');
         Login(data[0], data[1]);
    }

Everything seems right BUT I am getting a

After lots of debugs I am not able to understand WHY Application.ExternalCall is throwing this exception.

Any hints??

Did you try just Application.ExternalCall(“InjectData”);? It looks like your intention is to send no parameters but instead you are sending null as a parameter. :slight_smile:

Hello! Just to give a feedback, Yes, you are right @kognito1 ! I should not to send a null as a second parameter… thanks!