I am trying to build a Unity application to be deployed with WebGL. I am trying to incorporate Google Sign-In into the application, and so far, this was what I've managed to make work in the Unity WebGL build in Chrome:
- User presses on the "Login with Google" button on Unity application, in Tab A.
- User is directed to Google Sign In page on another Tab B.
- User signs in with Google account, and is redirected to my
redirect_uri
, which is simplyhttps://localhost
, with theauth
code parameter.
My question is, is it possible for me to do the following, possible with .jslib
files:
- Instead of going to
redirect_uri
on Tab B, instead go back to Tab A without reloading, passing along theauth
code. - Building on the line above, have javascript handlers, that:
- When auth code is received, initiate request to exchange auth code for the id_token as instructed here.
- When id_token is received, call a C# Script function to do further actions with the id_token.
Alternatively, I can set redirect_uri
to be an endpoint on my backend server, and perform the auth token -> id_token flow using the Google client SDKs. However, for this approach, I would like to know if i am able to
- After the auth token -> id_token flow is completed on the backend server, close the current window, Tab B, and go back to Tab A.
- After we’re back on Tab A, redirect Unity to a specific scene (not the login scene anymore, but a home page that users are directed to after they are authenticated).
Would very much appreciate any help i can get :')
EDIT: For better clarity, what I want to achieve is something that FacebookSDK for Unity has done in their FB.LogInWithReadPermissions()
. The whole auth code -> access_token flow is seamless, and i get redirected back to the Unity application in Tab A at the end with the access_token.