How to access Amazon Location service for the "Place indexes" endpoint only

434 Views Asked by At

Introduction of my problem I am trying to set up the Amazon Location Service Place indexes API to retrieve suggestions of places and coordinates. However, I am having difficulty understanding how to access the API and set up the necessary credentials. Specifically, I'm unsure whether it's better to use an API key or create a role in the IAM console for authentication.

I am new to Amazon Location Service and am not familiar with the best practices for setting it up. Therefore, any guidance on how to properly set up the service would be greatly appreciated.

My needs In my web application, I need to implement a dropdown that will be filled with places suggestions, based on the request I want to make to Amazon Location. For example, if the user write "New" in the text input, I want to call the API and retrieve the most related places, like "New York", "New Brunswick", "New Hampshire", etc.

So if the user select one of these places, I can retrieve their coordinates (lat, lng).

My applications My web application is an MVC project that use the .NET Framework 6.0.

I absolutely want to use the Amazon Location service, because my application is using other services from AWS.

What I've tried I've tried the AWSSDK.LocationService to make call to their API, without success. Each time I've tried, I got this error:

{ "message": "Unable to determine service/operation name to be authorized" }

I was using an API Key that I generated and passing it like this: "x-api-key", "my-api-key". The endpoint I was using is: "https://places.geo.ca-central-1.amazonaws.com/places/v0/indexes/..." (ca-central-1 is the right datacenter).

1

There are 1 best solutions below

2
On

Amazon Location Service currently supports API Keys in preview for only Maps. So use Amazon Cognito to handle authentication. Visit the Grant Access to Amazon Location page to learn more about it.

I've also written a blog post about this use case - it shows you how to create a map with a location search widget using Amplify Geo and Vue.js. I'd suggest you follow that if you're OK with using Amplify in your project.

If you'd like to use the AWS SDK for JavaScript, take a look at another blog post of mine, which shows how to call Amazon Location's Routes API to get directions from A to B. Calling Places API would be very similar to this - see the calculateRoute function to see how it's done.

Hope this helps.