Authentication

Initialize the RGN SDK

using ReadyGamesNetwork.RGN;
using ReadyGamesNetwork.RGN.Modules;
using ReadyGamesNetwork.RGN.Model;
​
// AppplicationStore Object, Can be found in ReadyGamesNetwork Folder
​​[SerializeField] private ApplicationStore applicationStore;
​
// Awake function from Unity's MonoBehavior
public void Awake()
{
// Add required Modules
RGNCoreBuilder.AddModule(new AppleSignInModule());
RGNCoreBuilder.AddModule(new GoogleSignInModule(applicationStore.googleSignInWebClientID));
RGNCoreBuilder.AddModule(new FacebookSignInModule());
RGNCoreBuilder.AddModule(new GuestSignInModule());
RGNCoreBuilder.AddModule(new UserProfileModule<RGNGameUserFullProfileData>(applicationStore.RGNStorageURL));
RGNCoreBuilder.AddModule(new StoreModule());
// Build ReadyMakersNetwork
await RGNCoreBuilder.Build(
new AppOptions()
{
ApiKey = applicationStore.RGNMasterApiKey,
AppId = applicationStore.RGNMasterAppID,
ProjectId = applicationStore.RGNMasterProjectId
},
applicationStore.RGNStorageURL);
}

Subscribe Authentication Changed event

After Initialization of RGN, Subscribe RGNCoreBuilder.I.OnAuthenticationChanged Changed event, to handle authentication and returning users.
On SignIn with any Auth Provider, credentials are stored in Keystore(Android) & Keychain(IOS) files.
using ReadyGamesNetwork.RGN;
using ReadyGamesNetwork.RGN.Model;
using UnityEngine;
​
private void OnEnable()
{
RGNCoreBuilder.I.OnAuthenticationChanged += RGNManager_OnAuthenticationChanged;
}
​
private void OnDisable()
{
RGNCoreBuilder.I.OnAuthenticationChanged += RGNManager_OnAuthenticationChanged;
}
​
private async void RGNManager_OnAuthenticationChanged(EnumLoginState enumLoginState, EnumLoginError error)
{
switch (enumLoginState)
{
case EnumLoginState.Error:
//LoginState Error
break;
case EnumLoginState.Success:
RGNGameUserFullProfileData userProfileData = await ProfileController.LoadAndCacheAsync();
if (userProfileData == null)
{
//No Account found, Call Signout current user.
RGNCoreBuilder.I.SignOutRGN();
return;
}
else
{
//Successful login
Debug.Log("user logged In \n" +
"UID :" + userProfileData.userId + "\n" +
"Display Name :" + userProfileData.displayName + "\n" +
"Short UID :" + userProfileData.shortUID + "\n");
//Load other data from here
​
}
break;
case EnumLoginState.NotLoggedIn:
//User not loggedIn
//SignIn As Guest.
RGNCoreBuilder.I.GetModule<GuestSignInModule>().SignInAsGuest();
break;
}
}

Facebook Login/Logout

using ReadyGamesNetwork.RGN;
using ReadyGamesNetwork.RGN.Modules;
​
//Facebook Login
public void FBLogin()
{
RGNCoreBuilder.I.GetModule<FacebookSignInModule>().OnSignInFacebook(true);
}
​
//Facebook Logout
public void FBLogout()
{
RGNCoreBuilder.I.GetModule<FacebookSignInModule>().SignOutFromFacebook();
}

Google Login/Logout

using ReadyGamesNetwork.RGN;
using ReadyGamesNetwork.RGN.Modules;
​
//Google Login
public void GoogleLogin()
{
RGNCoreBuilder.I.GetModule<GoogleSignInModule>().OnSignInGoogle(true);
}
​
//Google Logout
public void GoogleLogout()
{
RGNCoreBuilder.I.GetModule<GoogleSignInModule>().SignOutFromGoogle();
}

Apple Login/Logout

using ReadyGamesNetwork.RGN;
using ReadyGamesNetwork.RGN.Modules;
​
//Apple Login
public void AppleLogin()
{
RGNCoreBuilder.I.GetModule<AppleSignInModule>().OnSignInWithApple(true);
}
​
//Apple Logout
public void AppleLogout()
{
RGNCoreBuilder.I.GetModule<AppleSignInModule>().SignOutFromApple();
}

Guest Login/Logout

using ReadyGamesNetwork.RGN;
using ReadyGamesNetwork.RGN.Modules;
​
//Guest Login
public void OnGuestSign()
{
RGNCoreBuilder.I.GetModule<GuestSignInModule>().SignInAsGuest();
}
​
//Guest Logout
public void OnGuestLogout()
{
RGNCoreBuilder.I.GetModule<GuestSignInModule>().SignOutGuest();
}
Copy link
On this page
Initialize the RGN SDK
Subscribe Authentication Changed event
Facebook Login/Logout
Google Login/Logout
Apple Login/Logout
Guest Login/Logout