//----- property -----

        //----- method -----

        public override void OnInspectorGUI()
        {
            instance = target as SpreadsheetConfig;

            if (connector == null)
            {
                connector = new SpreadsheetConnector();
                connector.Initialize(instance);
            }

            serializedObject.Update();

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.PropertyField(serializedObject.FindProperty("clientId"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("clientSecret"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("redirectUri"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("scope"));

            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }

            using (new DisableScope(connector.State != SpreadsheetConnector.AuthenticationState.SignIn))
            {
                EditorGUILayout.Separator();

                if (GUILayout.Button("SignOut"))
                {
                    connector.SignOut();
                }
            }
        }
Beispiel #2
0
        //----- method -----

        public void Initialize(SpreadsheetConfig config)
        {
            this.config = config;

            System.Net.ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => true;

            DateTime dt;

            parameters = GetRawOAuth2Parameters();

            parameters.AccessToken  = SpreadsheetConnectorPrefs.accessTokenKey;
            parameters.RefreshToken = SpreadsheetConnectorPrefs.refreshTokenKey;

            if (DateTime.TryParse(SpreadsheetConnectorPrefs.tokenExpiryKey, out dt))
            {
                parameters.TokenExpiry = dt;
            }

            if (!string.IsNullOrEmpty(parameters.AccessToken))
            {
                service = CreateService(parameters);
                State   = AuthenticationState.SignIn;
            }
            else
            {
                State = AuthenticationState.SignOut;
            }
        }