chore(v1): Pin rsa to 4.5 for Python 2.7 compatibility (#1205)
As python 2.7 is no longer supported in master, this fix is only intended for the [v1](https://github.com/googleapis/google-api-python-client/tree/v1) branch where we still have support for python 2.7.
Fixes #1204 🦕
diff --git a/setup.py b/setup.py
index bf0a8f4..8086749 100644
--- a/setup.py
+++ b/setup.py
@@ -39,6 +39,8 @@
"google-auth>=1.16.0",
"google-auth-httplib2>=0.0.3",
"google-api-core>=1.21.0,<2dev",
+ # rsa version 4.5 is the last version that is compatible with Python 2.7
+ "rsa==4.5;python_version<'3'",
"six>=1.13.0,<2dev",
"uritemplate>=3.0.0,<4dev",
]
diff --git a/tests/test__auth.py b/tests/test__auth.py
index 9c4ea65..5923e8d 100644
--- a/tests/test__auth.py
+++ b/tests/test__auth.py
@@ -18,6 +18,7 @@
import google_auth_httplib2
import httplib2
import oauth2client.client
+import pkg_resources
import unittest2 as unittest
from googleapiclient import _auth
@@ -82,6 +83,8 @@
):
pass
+ google_auth_version = pkg_resources.get_distribution("google-auth").parsed_version
+
credentials = mock.Mock(spec=CredentialsWithScopes)
credentials.requires_scopes = True
@@ -89,7 +92,12 @@
self.assertNotEqual(credentials, returned)
self.assertEqual(returned, credentials.with_scopes.return_value)
- credentials.with_scopes.assert_called_once_with(mock.sentinel.scopes)
+
+ # The `default_scopes` argument was added in google-auth==1.25.0
+ if google_auth_version >= pkg_resources.parse_version("1.25.0"):
+ credentials.with_scopes.assert_called_once_with(mock.sentinel.scopes, default_scopes=None)
+ else:
+ credentials.with_scopes.assert_called_once_with(mock.sentinel.scopes)
def test_authorized_http(self):
credentials = mock.Mock(spec=google.auth.credentials.Credentials)