Search code examples
c#uwpwindows-10windows-10-universalbing-api

"InvalidCredentials" error in UWP reverse geo code API


I'm getting the following error when I try to execute this code in my UWP app. I took the code from the official sample:

“InvalidCredentials” error in UWP reverse geo code API

BasicGeoposition location = new BasicGeoposition();
location.Latitude = 47.643;
location.Longitude = -122.131;
Geopoint pointToReverseGeocode = new Geopoint(location);

// Reverse geocode the specified geographic location.
MapLocationFinderResult result = await MapLocationFinder.FindLocationsAtAsync(pointToReverseGeocode);

// If the query returns results, display the name of the town
// contained in the address of the first result.
if (result.Status == MapLocationFinderStatus.Success)
{
    tbOutputText.Text = "town = " + result.Locations[0].Address.Town;
}

Solution

  • Go to https://www.bingmapsportal.com and create a key. Then add it to your app.

    MapService.ServiceToken = "MyKey";