Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion geocoder/ipinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from geocoder.base import OneResult, MultipleResultsQuery
from geocoder.location import Location

from geocoder.keys import ipinfo_key

class IpinfoResult(OneResult):

Expand Down Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion geocoder/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down