Repository: praw-dev/praw

Issue:
Reddit._core._authorizer is set to an prawcore.auth.ScriptAuthorizer instance when password is not given
## Issue Description

To reproduce:

```
$ python2
Python 2.7.12 (default, Jun 29 2016, 14:05:02)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import praw
>>> reddit = praw.Reddit(client_id="ID", client_secret="SECRET", user_agent="UA")
>>> reddit._core._authorizer
<prawcore.auth.ScriptAuthorizer object at 0x100e776d0>
>>> reddit.config.username
<object object at 0x100533130>
>>> reddit.config.password
<object object at 0x100533130>
```

Since ScriptAuthorizer manages password grant flow which requires username and password,  I think this behavior is not correct.
## System Information
- PRAW Version: latest comimit b7b03fc
- Python Version: 2.7.12
- Operating System: Mac OS X 10.11.6



Discussion:
Thanks for filing. Looking into it.


Resolving patch:
diff --git a/praw/config.py b/praw/config.py
--- a/praw/config.py
+++ b/praw/config.py
@@ -7,11 +7,21 @@
 from .exceptions import ClientException
 
 
+class _NotSet(object):
+    def __bool__(self):
+        return False
+
+    __nonzero__ = __bool__
+
+    def __str__(self):
+        return 'NotSet'
+
+
 class Config(object):
     """A class containing the configuration for a reddit site."""
 
     CONFIG = None
-    CONFIG_NOT_SET = object()  # Represents a config value that is not set.
+    CONFIG_NOT_SET = _NotSet()  # Represents a config value that is not set.
 
     @classmethod
     def _load_config(cls):
diff --git a/praw/reddit.py b/praw/reddit.py
--- a/praw/reddit.py
+++ b/praw/reddit.py
@@ -3,9 +3,9 @@
 
 from six import iteritems
 from update_checker import update_check
-from prawcore import (DeviceIDAuthorizer, ReadOnlyAuthorizer, Redirect,
-                      Requestor, ScriptAuthorizer, TrustedAuthenticator,
-                      UntrustedAuthenticator, session)
+from prawcore import (Authorizer, DeviceIDAuthorizer, ReadOnlyAuthorizer,
+                      Redirect, Requestor, ScriptAuthorizer,
+                      TrustedAuthenticator, UntrustedAuthenticator, session)
 
 from .exceptions import ClientException
 from .config import Config
@@ -166,6 +166,9 @@ def _prepare_trusted_prawcore(self, requestor):
             script_authorizer = ScriptAuthorizer(
                 authenticator, self.config.username, self.config.password)
             self._core = self._authorized_core = session(script_authorizer)
+        elif self.config.refresh_token:
+            authorizer = Authorizer(authenticator, self.config.refresh_token)
+            self._core = self._authorized_core = session(authorizer)
         else:
             self._core = self._read_only_core
 


Test patch:
diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py
--- a/tests/unit/test_config.py
+++ b/tests/unit/test_config.py
@@ -89,3 +89,7 @@ def test_short_url_not_defined(self):
         with pytest.raises(ClientException) as excinfo:
             config.short_url
         assert str(excinfo.value) == 'No short domain specified.'
+
+    def test_unset_value_has_useful_string_representation(self):
+        config = Config('DEFAULT')
+        assert str(config.password) == 'NotSet'
diff --git a/tests/unit/test_reddit.py b/tests/unit/test_reddit.py
--- a/tests/unit/test_reddit.py
+++ b/tests/unit/test_reddit.py
@@ -26,6 +26,15 @@ def test_context_manager(self):
     def test_multireddit(self):
         assert self.reddit.multireddit('bboe', 'aa').path == '/user/bboe/m/aa'
 
+    def test_read_only__with_authenticated_core(self):
+        with Reddit(password=None, refresh_token='refresh', username=None,
+                    **self.REQUIRED_DUMMY_SETTINGS) as reddit:
+            assert not reddit.read_only
+            reddit.read_only = True
+            assert reddit.read_only
+            reddit.read_only = False
+            assert not reddit.read_only
+
     def test_read_only__with_script_authenticated_core(self):
         with Reddit(password='dummy', username='dummy',
                     **self.REQUIRED_DUMMY_SETTINGS) as reddit: