public override void RequestAuth(AuthResultCallback callback = null, bool reset_auth = false)
    {
        DebugLogger.Log("[AdvertisingIdAuthProvider] RequestAuth");

        mAuthResultCallback = callback;

        void advertising_id_callback(string advertising_id, bool tracking_enabled, string error)
        {
            var error_string = string.IsNullOrEmpty(error) ? "" : ", error: " + error;

            DebugLogger.Log($"[AdvertisingIdAuthProvider] advertising_id : {advertising_id} {error_string}");

            AdvertisingId = advertising_id;

            if (CheckAdvertisingId(advertising_id))
            {
                RequestLogin(ProviderId, advertising_id, "", reset_auth);
            }
            else
            {
                DebugLogger.Log("[AdvertisingIdAuthProvider] advertising id is invalid");

                InvokeAuthFailCallback(SnipeErrorCodes.NOT_INITIALIZED);
            }
        }

        if (!Application.RequestAdvertisingIdentifierAsync(advertising_id_callback))
        {
            DebugLogger.Log("[AdvertisingIdAuthProvider] advertising id is not supported on this platform");

            InvokeAuthFailCallback(SnipeErrorCodes.NOT_INITIALIZED);
        }
    }
        private void InvokeAuthFailCallback(string error_code)
        {
            mAuthResultCallback?.Invoke(error_code, 0);
            mAuthResultCallback = null;

            mCurrentProvider?.Dispose();
            mCurrentProvider = null;
        }
        public void Authorize(AuthResultCallback callback = null)
        {
            if (mCurrentProvider == null)
            {
                SwitchToNextAuthProvider();
            }

            AuthorizeWithCurrentProvider(callback);
        }
        public virtual void RequestAuth(AuthResultCallback callback = null, bool reset_auth = false)
        {
            // Override this method.

            //mAuthSuccessCallback = success_callback;
            //mAuthFailCallback = fail_callback;

            InvokeAuthFailCallback(SnipeErrorCodes.NOT_INITIALIZED);
        }
Exemple #5
0
    public override void RequestAuth(AuthResultCallback callback = null, bool reset_auth = false)
    {
        DebugLogger.Log("[DeviceIdAuthProvider] RequestAuth");

        mAuthResultCallback = callback;

        if (SystemInfo.unsupportedIdentifier != SystemInfo.deviceUniqueIdentifier)
        {
            RequestLogin(ProviderId, GetUserId(), "", reset_auth);
        }
        else
        {
            InvokeAuthFailCallback(SnipeErrorCodes.NOT_INITIALIZED);
        }
    }
        public void Authorize <ProviderType>(AuthResultCallback callback = null) where ProviderType : AuthProvider
        {
            mCurrentProvider = GetAuthProvider <ProviderType>();

            if (mCurrentProvider == null)
            {
                DebugLogger.Log("[SnipeAuthCommunicator] Authorize<ProviderType> - provider not found");

                callback?.Invoke(SnipeErrorCodes.NOT_INITIALIZED, 0);

                return;
            }

            AuthorizeWithCurrentProvider(callback);
        }
        public override void RequestAuth(AuthResultCallback callback = null, bool reset_auth = false)
        {
            mAuthResultCallback = callback;

            string auth_login = PlayerPrefs.GetString(SnipePrefs.AUTH_UID);
            string auth_token = PlayerPrefs.GetString(SnipePrefs.AUTH_KEY);

            if (!string.IsNullOrEmpty(auth_login) && !string.IsNullOrEmpty(auth_token))
            {
                RequestLogin(ProviderId, auth_login, auth_token, reset_auth);
            }
            else
            {
                InvokeAuthFailCallback(SnipeErrorCodes.NOT_INITIALIZED);
            }
        }
        public void Authorize(bool reset, AuthResultCallback callback = null)
        {
            if (reset)             // forget previous provider and start again from the beginning
            {
                AuthProvider prev_provider = mCurrentProvider;

                mCurrentProvider = null;
                SwitchToNextAuthProvider();

                if (prev_provider != mCurrentProvider)
                {
                    prev_provider.Dispose();
                }
            }

            Authorize(callback);
        }
    public override void RequestAuth(AuthResultCallback callback = null, bool reset_auth = false)
    {
        mAuthResultCallback = callback;

        if (FB.IsLoggedIn && AccessToken.CurrentAccessToken != null)
        {
            RequestLogin(ProviderId, AccessToken.CurrentAccessToken.UserId, AccessToken.CurrentAccessToken.TokenString, reset_auth);
            return;
        }

        if (!FacebookProvider.InstanceInitialized)
        {
            FacebookProvider.InstanceInitializationComplete -= OnFacebookProviderInitializationComplete;
            FacebookProvider.InstanceInitializationComplete += OnFacebookProviderInitializationComplete;
        }

        InvokeAuthFailCallback(SnipeErrorCodes.NOT_INITIALIZED);
    }
 private void InvokeAuthSuccessCallback(int user_id)
 {
     mAuthResultCallback?.Invoke(SnipeErrorCodes.OK, user_id);
     mAuthResultCallback = null;
 }
 protected void AuthorizeWithCurrentProvider(AuthResultCallback callback = null)
 {
     JustRegistered      = false;
     mAuthResultCallback = callback;
     CurrentProviderRequestAuth();
 }
 public virtual void Dispose()
 {
     mAuthResultCallback = null;
 }
 protected virtual void InvokeAuthFailCallback(string error_code)
 {
     mAuthResultCallback?.Invoke(error_code, 0);
     mAuthResultCallback = null;
 }
 protected virtual void InvokeAuthSuccessCallback(int user_id)
 {
     mAuthResultCallback?.Invoke(SnipeErrorCodes.OK, user_id);
     mAuthResultCallback = null;
 }