Repository: mollie/mollie-api-python

Issue:
Add support for OAuth access tokens
By default, OAuth access tokens are not accepted in this package, while other packages do have support (e.g. mollie-api-php). 

I took a look there and found that there's little difference between access_token and API Key calls. The only difference is an additional User Agent header and a hardcoded validation on the API key starting with 'test_' or 'live_' in `validate_api_key()`.

I found a simple workaround to make this package work by avoiding the methods `validate_api_key()` and `set_api_key()`:
 ```python
client = Client()
client.api_key = access_token
client.USER_AGENT += " OAuth/2.0"
```

Maybe it's better to implement this in the package itself (with the necessary validation checks of course).

Discussion:

Patch:
diff --git a/mollie/api/client.py b/mollie/api/client.py
index fd757f0..79fcc59 100644
--- a/mollie/api/client.py
+++ b/mollie/api/client.py
@@ -2,6 +2,7 @@ import json
 import platform
 import re
 import ssl
+import warnings
 
 import requests
 
@@ -50,10 +51,19 @@ class Client(object):
                 "Invalid API key: '{api_key}'. An API key must start with 'test_' or 'live_'.".format(api_key=api_key))
         return api_key
 
+    @staticmethod
+    def validate_access_token(access_token):
+        access_token = access_token.strip()
+        if not access_token.startswith('access_'):
+            raise RequestSetupError(
+                "Invalid access token: '{access_token}'. An access token must start with 'access_'.".format(
+                    access_token=access_token))
+        return access_token
+
     def __init__(self, api_key=None, api_endpoint=None, timeout=10):
         self.api_endpoint = self.validate_api_endpoint(api_endpoint or self.API_ENDPOINT)
         self.api_version = self.API_VERSION
-        self.api_key = self.validate_api_key(api_key) if api_key else None
+        self.api_key = None
         self.timeout = timeout
         self.payments = Payments(self)
         self.payment_refunds = PaymentRefunds(self)
@@ -68,12 +78,26 @@ class Client(object):
         self.orders = Orders(self)
         self.subscription_payments = SubscriptionPayments(self)
 
+        if api_key:
+            # There is no clean way for supporting both API key and access token acceptance and validation
+            #  in __init__(). Furthermore the naming of the parameter would be inconsistent.
+            # Using class methods is way cleaner.
+            #
+            # Warning added in 2.1.1, remove support in 2.3.x or so.
+            msg = "Setting the API key during init will be removed in the future. " \
+                  "Use Client.set_api_key() or Client.set_access_token() instead."
+            warnings.warn(msg, PendingDeprecationWarning)
+            self.api_key = self.validate_api_key(api_key)
+
     def set_api_endpoint(self, api_endpoint):
         self.api_endpoint = self.validate_api_endpoint(api_endpoint)
 
     def set_api_key(self, api_key):
         self.api_key = self.validate_api_key(api_key)
 
+    def set_access_token(self, access_token):
+        self.api_key = self.validate_access_token(access_token)
+
     def set_timeout(self, timeout):
         self.timeout = timeout
 


Test patch:
diff --git a/tests/test_client.py b/tests/test_client.py
index c17387c..028094e 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -48,6 +48,20 @@ def test_client_querystring(client, response):
     assert methods.count == 11
 
 
+def test_client_api_key():
+    """Setting up a valid api key or access token should be possible."""
+    client = Client()
+
+    client.set_access_token('access_123')
+    assert client.api_key == 'access_123'
+
+    client.set_api_key('live_123')
+    assert client.api_key == 'live_123'
+
+    client.set_api_key('test_123')
+    assert client.api_key == 'test_123'
+
+
 def test_client_no_api_key():
     """A Request without an API key should raise an error."""
     client = Client()
@@ -58,9 +72,30 @@ def test_client_no_api_key():
 def test_client_invalid_api_key():
     """Setting up an invalid api key raises an error."""
     client = Client()
+
     with pytest.raises(RequestSetupError, match="Invalid API key: 'invalid'"):
         client.set_api_key('invalid')
 
+    with pytest.raises(RequestSetupError, match="Invalid API key: 'access_123'"):
+        client.set_api_key('access_123')
+
+    with pytest.raises(RequestSetupError, match="Invalid access token: 'invalid'"):
+        client.set_access_token('invalid')
+
+    with pytest.raises(RequestSetupError, match="Invalid access token: 'live_123'"):
+        client.set_access_token('live_123')
+
+    with pytest.raises(RequestSetupError, match="Invalid access token: 'test_123'"):
+        client.set_access_token('test_123')
+
+
+def test_client_api_key_during_init_deprecated(recwarn):
+    """Setting the api key during init should work but raise a warning."""
+    with pytest.warns(PendingDeprecationWarning,
+                      match='Setting the API key during init will be removed in the future'):
+        client = Client(api_key='test_123')
+    assert client.api_key == 'test_123'
+
 
 def test_client_broken_cert_bundle(monkeypatch):
     """