diff --git a/src/octokit/__init__.py b/src/octokit/__init__.py index 62b4edd..645067e 100644 --- a/src/octokit/__init__.py +++ b/src/octokit/__init__.py @@ -98,7 +98,7 @@ class Base(object): } installation_url = '{}/app/installations'.format(self.base_url) installations = requests.get(installation_url, headers=headers).json() - self.installation_id = [x.get('id') for x in installations if x.get('app_id') == app_id].pop() + self.installation_id = [x.get('id') for x in installations if str(x.get('app_id')) == app_id].pop() installation_token_url = '{}/installations/{}/access_tokens'.format(self.base_url, self.installation_id) response = requests.post(installation_token_url, headers=headers).json() return response['token'], response['expires_at'] diff --git a/tests/test_auth.py b/tests/test_auth.py index ea59f78..a24f754 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -66,7 +66,7 @@ class TestAuth(object): post.return_value = Request(json=lambda: {'token': 'v1.1f699f1069f60', 'expires_at': '2016-07-11T22:14:10Z'}) with open(os.path.join(os.path.dirname(__file__), 'test.pem'), 'r') as f: private_key = f.read() - sut = Octokit(auth='installation', app_id=42, private_key=private_key) + sut = Octokit(auth='installation', app_id='42', private_key=private_key) assert sut.auth == 'installation' assert sut.token == 'v1.1f699f1069f60' assert sut.expires_at == '2016-07-11T22:14:10Z' @@ -77,9 +77,9 @@ class TestAuth(object): with pytest.raises(AssertionError): Octokit(auth='installation', app_id='') with pytest.raises(KeyError): - Octokit(auth='installation', app_id=42) + Octokit(auth='installation', app_id='42') with pytest.raises(AssertionError): - Octokit(auth='installation', app_id=42, private_key='') + Octokit(auth='installation', app_id='42', private_key='') def test_installation_token_is_used_if_set(self, mocker): Request = namedtuple('Request', ['json']) @@ -89,7 +89,7 @@ class TestAuth(object): post.return_value = Request(json=lambda: {'token': 'v1.1f699f1069f60', 'expires_at': '2016-07-11T22:14:10Z'}) with open(os.path.join(os.path.dirname(__file__), 'test.pem'), 'r') as f: private_key = f.read() - sut = Octokit(auth='installation', app_id=42, private_key=private_key) + sut = Octokit(auth='installation', app_id='42', private_key=private_key) assert sut.installation_id == 37 get = mocker.patch('requests.get') sut.authorization.get(id=100)