anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: authomatic/authomatic
Issue: Facebook provider set incorrect token_type

I got following error, when I'm trying to get result.popup_html().
```
File "/home/user/.virtualenvs/kurjerzy-3.5.1/lib/python3.5/site-packages/authomatic/providers/oauth2.py", line 213, in to_tuple
    cls.TOKEN_TYPES.index(credentials.token_type))
ValueError: 'bearer' is not in list
```
credentials.token_type is "bearer" not "Bearer"

I think the fix is to add 

```
if data.get('token_type') == 'bearer':
    credentials.token_type = cls.BEARER
```
in oauth2.py, Facebook class, method _x_credentials_parser(credentials, data)

Changed files:
authomatic/providers/oauth2.py

diff --git a/authomatic/providers/oauth2.py b/authomatic/providers/oauth2.py
index 696196b..7fe8777 100644
--- a/authomatic/providers/oauth2.py
+++ b/authomatic/providers/oauth2.py
@@ -859,7 +859,10 @@ class Facebook(OAuth2):
         
         # Facebook returns "expires" instead of "expires_in".
         credentials.expire_in = data.get('expires')
-        
+
+        if data.get('token_type') == 'bearer':
+            credentials.token_type = cls.BEARER
+
         return credentials
Repository: authomatic/authomatic
Issue: Twitter location data handling

Something I ran into testing the Flask example and logging in via Twitter. If you're like me, and only had your city in the location field (i.e., Perth, instead of Perth, Australia), this would cause Authomatic to bomb out the login with the error below originating from line 659 of oauth1.py.

_city, _country = _location.split(',')
ValueError: need more than 1 value to unpack


Changed files:
authomatic/providers/oauth1.py

diff --git a/authomatic/providers/oauth1.py b/authomatic/providers/oauth1.py
index b9443f8..1869453 100644
--- a/authomatic/providers/oauth1.py
+++ b/authomatic/providers/oauth1.py
@@ -836,6 +836,16 @@ class Twitter(OAuth1):
         user.picture = data.get('profile_image_url')
         user.locale = data.get('lang')
         user.link = data.get('url')
+        _location = data.get('location', '')
+        if _location:
+            user.location = _location.strip()
+            _split_location = _location.split(',')
+            if len(_split_location) > 1:
+                _city, _country = _split_location
+                user.country = _country.strip()
+            else:
+                _city = _split_location[0]
+            user.city = _city.strip()
         return user
Repository: authomatic/authomatic
Issue: decoding utf-8 from response content breaks on binary files

You added .decode('utf-8') to the content property method in 998e21b94bd2c3f80c4926d4df8f385d42310848 -- unfortunately, this breaks when the response body is binary data. I think I have a solution; I'll send a pull request if/when I do.


Changed files:
authomatic/providers/__init__.py, authomatic/core.py

diff --git a/authomatic/core.py b/authomatic/core.py
index 0b9e1b7..cf2b9b9 100644
--- a/authomatic/core.py
+++ b/authomatic/core.py
@@ -1085,6 +1085,15 @@ class Response(ReprMixin):
         return self.httplib_response.getheaders()
 
 
+    def is_binary_string(self, content):
+        """
+        Return true if string is binary data
+        """
+
+        textchars = bytearray([7,8,9,10,12,13,27]) + bytearray(range(0x20, 0x100))
+        return bool(content.translate(None, textchars))
+
+
     @property
     def content(self):
         """
@@ -1092,7 +1101,11 @@ class Response(ReprMixin):
         """
 
         if not self._content:
-            self._content = self.httplib_response.read().decode('utf-8')
+            content = self.httplib_response.read()
+            if self.is_binary_string(content):
+                self._content = content
+            else:
+                self._content = content.decode('utf-8')
         return self._content
 
 
diff --git a/authomatic/providers/__init__.py b/authomatic/providers/__init__.py
index 919b64f..e8664a6 100644
--- a/authomatic/providers/__init__.py
+++ b/authomatic/providers/__init__.py
@@ -373,7 +373,6 @@ class BaseProvider(object):
                 body = query
                 query = ''
                 headers.update({'Content-Type': 'application/x-www-form-urlencoded'})
-        print(path, query)
         request_path = parse.urlunsplit(('', '', path or '', query or '', ''))
         
         self._log(logging.DEBUG, ' \\u251C\\u2500 host: {0}'.format(host))
Repository: authomatic/authomatic
Issue: FailureError('Unable to retrieve token secret from storage!',)

Some users are reporting lost session after redirect within the _login procedure_.

the original issue as opened by @petertirrell was:
# Pyramid Adapter and example

Implement an adapter for the Pyramid framework with example.


Changed files:
authomatic/core.py

diff --git a/authomatic/core.py b/authomatic/core.py
index f397a42..acd6048 100644
--- a/authomatic/core.py
+++ b/authomatic/core.py
@@ -352,13 +352,18 @@ class Session(object):
             Expires value will be ``Thu, 01-Jan-1970 00:00:01 GMT``.
         """
 
-        template = '{name}={value}; Domain={domain}; Path={path}; HttpOnly{secure}{expires}'
-
         value = 'deleted' if delete else self._serialize(self.data)
 
         split_url = urlparse.urlsplit(self.adapter.url)
         domain = split_url.netloc.split(':')[0]
 
+        # Work-around for issue #11, failure of WebKit-based browsers to accept
+        # cookies set as part of a redirect response in some circumstances.
+        if not '.' in domain:
+            template = '{name}={value}; Path={path}; HttpOnly{secure}{expires}'
+        else:
+            template = '{name}={value}; Domain={domain}; Path={path}; HttpOnly{secure}{expires}'
+
         return template.format(name=self.name,
                                value=value,
                                domain=domain,