///<summary></summary> /// <seealso cref="GooglePlayGames.BasicApi.IPlayGamesClient.Authenticate"/> public void Authenticate(Action <bool, string> callback, bool silent) { lock (AuthStateLock) { // If the user is already authenticated, just fire the callback, we don't need // any additional work. if (mAuthState == AuthState.Authenticated) { InvokeCallbackOnGameThread(callback, true, null); return; } // If this is silent auth, and silent auth already failed, there's no point in // trying again. if (mSilentAuthFailed && silent) { InvokeCallbackOnGameThread(callback, false, "silent auth failed"); return; } // Otherwise, hold the callback for invocation. if (callback != null) { if (silent) { mSilentAuthCallbacks += callback; } else { mPendingAuthCallbacks += callback; } } } // If game services are uninitialized, creating them will start a silent auth attempt. InitializeGameServices(); // reset friends loading flag friendsLoading = false; if (mTokenClient.NeedsToRun()) { Debug.Log("Using AuthHelper to sign in"); mTokenClient.FetchTokens(() => GameServices().StartAuthorizationUI()); } if (!silent) { // If we need tokens or email, then get those first if (mTokenClient.NeedsToRun()) { mTokenClient.FetchTokens(() => GameServices().StartAuthorizationUI()); } else { GameServices().StartAuthorizationUI(); } } }
public void Authenticate(Action <bool, string> callback, bool silent) { lock (AuthStateLock) { if (mAuthState == AuthState.Authenticated) { InvokeCallbackOnGameThread(callback, true, null); return; } if (mSilentAuthFailed && silent) { InvokeCallbackOnGameThread(callback, false, "silent auth failed"); return; } if (callback != null) { if (silent) { mSilentAuthCallbacks = (Action <bool, string>)Delegate.Combine(mSilentAuthCallbacks, callback); } else { mPendingAuthCallbacks = (Action <bool, string>)Delegate.Combine(mPendingAuthCallbacks, callback); } } } InitializeGameServices(); friendsLoading = false; if (mTokenClient.NeedsToRun()) { Debug.Log((object)"Using AuthHelper to sign in"); mTokenClient.FetchTokens(delegate { GameServices().StartAuthorizationUI(); }); } if (!silent) { if (mTokenClient.NeedsToRun()) { mTokenClient.FetchTokens(delegate { GameServices().StartAuthorizationUI(); }); } else { GameServices().StartAuthorizationUI(); } } }
///<summary></summary> /// <seealso cref="GooglePlayGames.BasicApi.IPlayGamesClient.Authenticate"/> public void Authenticate(Action <bool, string> callback, bool silent) { lock (AuthStateLock) { // If the user is already authenticated, just fire the callback, we don't need // any additional work. if (mAuthState == AuthState.Authenticated) { InvokeCallbackOnGameThread(callback, true, null); return; } } // reset friends loading flag friendsLoading = false; InitializeTokenClient(); Debug.Log("Starting Auth with token client."); mTokenClient.FetchTokens(silent, (int result) => { bool succeed = result == 0 /* CommonStatusCodes.SUCCEED */; InitializeGameServices(); if (succeed) { if (callback != null) { mPendingAuthCallbacks += callback; } GameServices().StartAuthorizationUI(); // Update achievements cache LoadAchievements(ignore => {}); } else { Action <bool, string> localCallback = callback; if (result == 16 /* CommonStatusCodes.CANCELED */) { InvokeCallbackOnGameThread(localCallback, false, "Authentication canceled"); } else if (result == 8 /* CommonStatusCodes.DEVELOPER_ERROR */) { InvokeCallbackOnGameThread(localCallback, false, "Authentication failed - developer error"); } else { InvokeCallbackOnGameThread(localCallback, false, "Authentication failed"); } } }); }
///<summary></summary> /// <seealso cref="GooglePlayGames.BasicApi.IPlayGamesClient.Authenticate"/> public void Authenticate(Action <bool, string> callback, bool silent) { lock (AuthStateLock) { // If the user is already authenticated, just fire the callback, we don't need // any additional work. if (mAuthState == AuthState.Authenticated) { InvokeCallbackOnGameThread(callback, true, null); return; } } // reset friends loading flag friendsLoading = false; InitializeTokenClient(); Debug.Log("Starting Auth with token client."); mTokenClient.FetchTokens(silent, (int result) => { bool succeed = result == 0; if (succeed) { if (callback != null) { mPendingAuthCallbacks += callback; } InitializeGameServices(); GameServices().StartAuthorizationUI(); } else { Action <bool, string> localCallback = callback; InvokeCallbackOnGameThread(localCallback, false, "Authentication failed"); } }); }
///<summary></summary> /// <seealso cref="GooglePlayGames.BasicApi.IPlayGamesClient.Authenticate"/> public void Authenticate(Action <bool, string> callback, bool silent) { lock (AuthStateLock) { // If the user is already authenticated, just fire the callback, we don't need // any additional work. if (mAuthState == AuthState.Authenticated) { InvokeCallbackOnGameThread(callback, true, null); return; } // If this is silent auth, and silent auth already failed, there's no point in // trying again. if (mSilentAuthFailed && silent) { InvokeCallbackOnGameThread(callback, false, "silent auth failed"); return; } // Otherwise, hold the callback for invocation. if (callback != null) { if (silent) { mSilentAuthCallbacks += callback; } else { mPendingAuthCallbacks += callback; } } } // reset friends loading flag friendsLoading = false; InitializeTokenClient(); // If we need to use the token client to authenticate, do that before initializing the GPG library. if (mTokenClient.NeedsToRun()) { Debug.Log("Starting Auth with token client."); mTokenClient.FetchTokens((int result) => { InitializeGameServices(); if (result == 0) { GameServices().StartAuthorizationUI(); } else { HandleAuthTransition(Types.AuthOperation.SIGN_IN, (Status.AuthStatus)result); } }); } else { // If game services are uninitialized, creating them will start a silent auth attempt. InitializeGameServices(); if (!silent) { GameServices().StartAuthorizationUI(); } } }