# Path: mangopay/exceptions.py
# class AuthenticationError(APIError):
#     pass


import base64
import hashlib
import json
import stat
import os
import tempfile
import six
import time
import mangopay
from mangopay.exceptions import AuthenticationError
                token = auth_result[1]
            else:
                return None
            token['timestamp'] = time.time() + (int(token['expires_in']) - 10)
            self.set_token(token)

        return token['token_type'] + ' ' + token['access_token']

    def set_token(self, token):
        self.storage_strategy.store(token, self.get_evn_key())

    def get_evn_key(self):
        return hashlib.md5((self._handler.client_id + self._handler.api_url +
                            self._handler.apikey).encode('utf-8')).hexdigest()


class ApiAuthorization(object):

    def __init__(self, handler):
        self._handler = handler

    def oauth_token(self):
        result = self._handler.request(method='POST',
                                       url='oauth/token',
                                       data={'grant_type': 'client_credentials'},
                                       oauth_request=True)
        return result

    def basic_token(self):
        if self._handler.client_id is None or self._handler.apikey is None:

# Path: mangopay/exceptions.py
# class AuthenticationError(APIError):
#     pass


# Path: mangopay/auth.py
import base64
import hashlib
import json
import stat
import os
import tempfile
import six
import time
import mangopay
from mangopay.exceptions import AuthenticationError

                token = auth_result[1]
            else:
                return None
            token['timestamp'] = time.time() + (int(token['expires_in']) - 10)
            self.set_token(token)

        return token['token_type'] + ' ' + token['access_token']

    def set_token(self, token):
        self.storage_strategy.store(token, self.get_evn_key())

    def get_evn_key(self):
        return hashlib.md5((self._handler.client_id + self._handler.api_url +
                            self._handler.apikey).encode('utf-8')).hexdigest()


class ApiAuthorization(object):

    def __init__(self, handler):
        self._handler = handler

    def oauth_token(self):
        result = self._handler.request(method='POST',
                                       url='oauth/token',
                                       data={'grant_type': 'client_credentials'},
                                       oauth_request=True)
        return result

    def basic_token(self):
        if self._handler.client_id is None or self._handler.apikey is None:

            raise AuthenticationError(