Skip to content

Commit 09155f1

Browse files
authored
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 🦕
1 parent d0110cf commit 09155f1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

‎setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
"google-auth>=1.16.0",
4040
"google-auth-httplib2>=0.0.3",
4141
"google-api-core>=1.21.0,<2dev",
42+
# rsa version 4.5 is the last version that is compatible with Python 2.7
43+
"rsa==4.5;python_version<'3'",
4244
"six>=1.13.0,<2dev",
4345
"uritemplate>=3.0.0,<4dev",
4446
]

‎tests/test__auth.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import google_auth_httplib2
1919
import httplib2
2020
import oauth2client.client
21+
import pkg_resources
2122
import unittest2 as unittest
2223

2324
from googleapiclient import _auth
@@ -82,14 +83,21 @@ class CredentialsWithScopes(
8283
):
8384
pass
8485

86+
google_auth_version = pkg_resources.get_distribution("google-auth").parsed_version
87+
8588
credentials = mock.Mock(spec=CredentialsWithScopes)
8689
credentials.requires_scopes = True
8790

8891
returned = _auth.with_scopes(credentials, mock.sentinel.scopes)
8992

9093
self.assertNotEqual(credentials, returned)
9194
self.assertEqual(returned, credentials.with_scopes.return_value)
92-
credentials.with_scopes.assert_called_once_with(mock.sentinel.scopes)
95+
96+
# The `default_scopes` argument was added in google-auth==1.25.0
97+
if google_auth_version >= pkg_resources.parse_version("1.25.0"):
98+
credentials.with_scopes.assert_called_once_with(mock.sentinel.scopes, default_scopes=None)
99+
else:
100+
credentials.with_scopes.assert_called_once_with(mock.sentinel.scopes)
93101

94102
def test_authorized_http(self):
95103
credentials = mock.Mock(spec=google.auth.credentials.Credentials)

0 commit comments

Comments
 (0)