Skip to content

Commit 3245f26

Browse files
committed
Use Personal Access Token authentication
as API Keys are currently deprecated and will be removed in January 2017
1 parent 467bb83 commit 3245f26

File tree

16 files changed

+35
-66
lines changed

16 files changed

+35
-66
lines changed

README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ Python bindings for the Intercom API (https://api.intercom.io).
88

99
[Package Documentation](http://readthedocs.org/docs/python-intercom/).
1010

11-
## Upgrading information
12-
13-
Version 2 of python-intercom is **not backwards compatible** with previous versions.
14-
15-
One change you will need to make as part of the upgrade is to set `Intercom.app_api_key` and not set `Intercom.api_key`.
16-
1711
## Installation
1812

1913
pip install python-intercom
@@ -23,10 +17,10 @@ One change you will need to make as part of the upgrade is to set `Intercom.app_
2317
### Configure your access credentials
2418

2519
```python
26-
Intercom.app_id = "my_app_id"
27-
Intercom.app_api_key = "my-super-crazy-api-key"
20+
Intercom.personal_access_token = "my_personal_access_token"
2821
```
2922

23+
Note that certain resources will require an extended scope access token : [Setting up Personal Access Tokens](https://developers.intercom.com/docs/personal-access-tokens>)
3024

3125
### Resources
3226

@@ -438,5 +432,5 @@ nosetests tests/unit
438432
Integration tests:
439433

440434
```bash
441-
INTERCOM_APP_ID=xxx INTERCOM_APP_API_KEY=xxx nosetests tests/integration
435+
INTERCOM_PERSONAL_ACCESS_TOKEN=xxx nosetests tests/integration
442436
```

README.rst

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@ Python bindings for the Intercom API (https://api.intercom.io).
1010
`Package
1111
Documentation <http://readthedocs.org/docs/python-intercom/>`__.
1212

13-
Upgrading information
14-
---------------------
15-
16-
Version 2 of python-intercom is **not backwards compatible** with
17-
previous versions.
18-
19-
One change you will need to make as part of the upgrade is to set
20-
``Intercom.app_api_key`` and not set ``Intercom.api_key``.
21-
2213
Installation
2314
------------
2415

@@ -34,8 +25,9 @@ Configure your access credentials
3425

3526
.. code:: python
3627
37-
Intercom.app_id = "my_app_id"
38-
Intercom.app_api_key = "my-super-crazy-api-key"
28+
Intercom.personal_access_token = "my_personal_access_token"
29+
30+
Note that certain resources will require an extended scope access token : `Setting up Personal Access Tokens <https://developers.intercom.com/docs/personal-access-tokens>`_
3931

4032
Resources
4133
~~~~~~~~~
@@ -474,7 +466,7 @@ Integration tests:
474466

475467
.. code:: bash
476468
477-
INTERCOM_APP_ID=xxx INTERCOM_APP_API_KEY=xxx nosetests tests/integration
469+
INTERCOM_PERSONAL_ACCESS_TOKEN=xxx nosetests tests/integration
478470
479471
.. |PyPI Version| image:: https://img.shields.io/pypi/v/python-intercom.svg
480472
:target: https://pypi.python.org/pypi/python-intercom

docs/development.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Run the integration tests:
1515
::
1616

1717
# THESE SHOULD ONLY BE RUN ON A TEST APP!
18-
INTERCOM_APP_ID=xxx INTERCOM_APP_API_KEY=xxx nosetests tests/integration
18+
INTERCOM_PERSONAL_ACCESS_TOKEN=xxx nosetests tests/integration
1919

2020
Generate the Documentation
2121
--------------------------

docs/index.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ Usage
2828
Authentication
2929
---------------
3030

31-
Intercom documentation: `Authentication <http://api.intercom.io/docs#authentication>`_.
31+
Intercom documentation: `Authentication <https://developers.intercom.com/docs#authentication>`_.
3232

3333
::
3434

3535
from intercom import Intercom
36-
Intercom.app_id = 'dummy-app-id'
37-
Intercom.app_api_key = 'dummy-api-key'
36+
Intercom.personal_access_token = 'dummy-personal-access-token'
3837

3938
Users
4039
-----

intercom/__init__.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,13 @@
3434
COMPATIBILITY_WARNING_TEXT = "It looks like you are upgrading from \
3535
an older version of python-intercom. Please note that this new version \
3636
(%s) is not backwards compatible." % (__version__)
37-
COMPATIBILITY_WORKAROUND_TEXT = "To get rid of this error please set \
38-
Intercom.app_api_key and don't set Intercom.api_key."
39-
CONFIGURATION_REQUIRED_TEXT = "You must set both Intercom.app_id and \
40-
Intercom.app_api_key to use this client."
37+
CONFIGURATION_REQUIRED_TEXT = "You must set Intercom.personal_access_token \
38+
to use this client."
4139

4240

4341
class IntercomType(type): # noqa
4442

45-
app_id = None
46-
app_api_key = None
43+
personal_access_token = None
4744
_hostname = "api.intercom.io"
4845
_protocol = "https"
4946
_endpoints = None
@@ -54,7 +51,7 @@ class IntercomType(type): # noqa
5451

5552
@property
5653
def _auth(self):
57-
return (self.app_id, self.app_api_key)
54+
return (self.personal_access_token, '')
5855

5956
@property
6057
def _random_endpoint(self):
@@ -74,11 +71,11 @@ def _alternative_random_endpoint(self):
7471

7572
@property
7673
def target_base_url(self):
77-
if None in [self.app_id, self.app_api_key]:
74+
if self.personal_access_token is None:
7875
raise ArgumentError('%s %s' % (
7976
CONFIGURATION_REQUIRED_TEXT, RELATED_DOCS_TEXT))
8077
if self._target_base_url is None:
81-
basic_auth_part = '%s:%s@' % (self.app_id, self.app_api_key)
78+
basic_auth_part = '%s:%s@' % (self.personal_access_token, '')
8279
if self.current_endpoint:
8380
self._target_base_url = re.sub(
8481
r'(https?:\/\/)(.*)',

tests/integration/issues/test_72.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
from intercom import Event
88
from intercom import User
99

10-
Intercom.app_id = os.environ.get('INTERCOM_APP_ID')
11-
Intercom.app_api_key = os.environ.get('INTERCOM_APP_API_KEY')
10+
Intercom.personal_access_token = os.environ.get('INTERCOM_PERSONAL_ACCESS_TOKEN')
1211

1312

1413
class Issue72Test(unittest.TestCase):

tests/integration/issues/test_73.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
from intercom import Intercom
99
from intercom import User
1010

11-
Intercom.app_id = os.environ.get('INTERCOM_APP_ID')
12-
Intercom.app_api_key = os.environ.get('INTERCOM_APP_API_KEY')
11+
Intercom.personal_access_token = os.environ.get('INTERCOM_PERSONAL_ACCESS_TOKEN')
1312

1413

1514
class Issue73Test(unittest.TestCase):

tests/integration/test_admin.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
from intercom import Intercom
66
from intercom import Admin
77

8-
Intercom.app_id = os.environ.get('INTERCOM_APP_ID')
9-
Intercom.app_api_key = os.environ.get('INTERCOM_APP_API_KEY')
8+
Intercom.personal_access_token = os.environ.get('INTERCOM_PERSONAL_ACCESS_TOKEN')
109

1110

1211
class AdminTest(unittest.TestCase):

tests/integration/test_company.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
from . import get_or_create_company
1111
from . import get_timestamp
1212

13-
Intercom.app_id = os.environ.get('INTERCOM_APP_ID')
14-
Intercom.app_api_key = os.environ.get('INTERCOM_APP_API_KEY')
13+
Intercom.personal_access_token = os.environ.get('INTERCOM_PERSONAL_ACCESS_TOKEN')
1514

1615

1716
class CompanyTest(unittest.TestCase):

tests/integration/test_conversations.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
from . import get_or_create_user
1111
from . import get_timestamp
1212

13-
Intercom.app_id = os.environ.get('INTERCOM_APP_ID')
14-
Intercom.app_api_key = os.environ.get('INTERCOM_APP_API_KEY')
13+
Intercom.personal_access_token = os.environ.get('INTERCOM_PERSONAL_ACCESS_TOKEN')
1514

1615

1716
class ConversationTest(unittest.TestCase):

0 commit comments

Comments
 (0)