I expected that open route service with give me the coordinates of the path from start to the end point but instead i got an error as Access to this API has been disallowed. Can someone please help me, with what i am doing wrong ?
import openrouteservice as ors
import os
import folium
API_KEY = os.environ['api_key']
client = ors.Client(key=API_KEY)
coordinates = [[-86.781247, 36.163532], [-80.191850, 25.771645]]
# directions
route = client.directions(coordinates=coordinates,
profile='driving-car',
format='geojson')
# map
map_directions = folium.Map(location=[33.77, -84.37], zoom_start=5)
# add geojson to map
folium.GeoJson(route, name='route').add_to(map_directions)
# add layer control to map (allows layer to be turned on or off)
folium.LayerControl().add_to(map_directions)
# display map
map_directions._repr_html_()
This is the error, I got:
raise exceptions.ApiError(
openrouteservice.exceptions.ApiError: 403 ({'error': 'Access to this API has been disallowed'})
For me, this error-code came up right after I started loading the API key as an environment variable. Turns out, the value loaded from
os.environcontained quotations on either end of the string because I mistakenly included them in my.envfile.This might not be your case, so -- generally speaking -- try to assert that the API key you load from
os.environis exactly what's given to you by Openrouteservice.I hope this helps.