Skip to content

Commit

Permalink
Add OAuth example without credentials objects #119
Browse files Browse the repository at this point in the history
  • Loading branch information
kPatch committed Nov 15, 2024
1 parent 8903449 commit 4d53003
Show file tree
Hide file tree
Showing 6 changed files with 1,084 additions and 0 deletions.
47 changes: 47 additions & 0 deletions Assets/Sui-Unity-SDK/SDK-Examples/FirebaseAuthManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Threading.Tasks;
using i5.Toolkit.Core.OpenIDConnectClient;
using i5.Toolkit.Core.ServiceCore;
using OpenDive.Utils.Jwt;
using UnityEngine;

public class FirebaseAuthManager : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{

}

// Update is called once per frame
void Update()
{

}

public void SignIn()
{
SignInWithGoogle();
}

private async Task SignInWithGoogle()
{
ServiceManager.GetService<OpenIDConnectService>().LoginCompleted += OnLoginCompleted;

Debug.Log(" +++ " + ServiceManager.GetService<OpenIDConnectService>().RedirectURI);
await ServiceManager.GetService<OpenIDConnectService>().OpenLoginPageAsync();
}

private void OnLoginCompleted(object sender, EventArgs e)
{
string accessToken = ServiceManager.GetService<OpenIDConnectService>().AccessToken;
Debug.Log("Sign In Done");
Debug.Log("TOKEN: " + accessToken);

JwtPayload jwt = JwtDecoder.DecodeJwt(accessToken);
Debug.Log(jwt.Aud + " ---- " + jwt.Iss
+ " ------ " + jwt.Sub
+ " ----- " + jwt.Exp
);
}
}
2 changes: 2 additions & 0 deletions Assets/Sui-Unity-SDK/SDK-Examples/FirebaseAuthManager.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4d53003

Please sign in to comment.