diff --git a/geocoder/ipinfo.py b/geocoder/ipinfo.py index 3cc50955..84e2eb2a 100644 --- a/geocoder/ipinfo.py +++ b/geocoder/ipinfo.py @@ -7,7 +7,7 @@ from geocoder.base import OneResult, MultipleResultsQuery from geocoder.location import Location - +from geocoder.keys import ipinfo_key class IpinfoResult(OneResult): @@ -74,8 +74,17 @@ class IpinfoQuery(MultipleResultsQuery): _URL = 'http://ipinfo.io/json' _RESULT_CLASS = IpinfoResult + _KEY = ipinfo_key _KEY_MANDATORY = False + def _build_headers(self, provider_key, **kwargs): + return { + 'Authorization': 'Bearer {}'.format(provider_key), + } + + def _build_params(self, location, provider_key, **kwargs): + return {} + def _before_initialize(self, location, **kwargs): if location.lower() == 'me' or location == '': self.url = 'http://ipinfo.io/json' diff --git a/geocoder/keys.py b/geocoder/keys.py index 6d42c2d9..4c71f348 100644 --- a/geocoder/keys.py +++ b/geocoder/keys.py @@ -25,7 +25,7 @@ geocodefarm_key = os.environ.get('GEOCODEFARM_API_KEY') tgos_key = os.environ.get('TGOS_API_KEY') locationiq_key = os.environ.get('LOCATIONIQ_API_KEY') - +ipinfo_key = os.environ.get('IPINFO_API_KEY') class CanadapostKeyLazySingleton(object):