Share via


How to authenticate a Maps app

Your app must be authenticated before it can use the MapControl and map services in the Windows.Services.Maps namespace. This topic describes how to authenticate a maps app for Windows Phone 8.1. To authenticate maps for Windows 10, see Request a maps authentication key.

Maps for Windows Phone 8.1 apps

When using maps in a Windows Phone 8.1 app, get the ApplicationID and AuthenticationToken for your app from the Windows Dev Center dashboard and add them to your app.

Step 1: Request an ApplicationID and AuthenticationToken

  1. In your browser, navigate to your developer dashboard in the Windows Dev Center.
  2. If you haven't yet, reserve your app's name.
  3. Look for the Services section in the left navigation menu, and expand it to show the Maps page.
  4. Click Get token, the ApplicationID and AuthenticationToken will be generated and will appear on this page.

Note  You don’t have to finish submitting your app at this time. After you request a token and ID, this info will be saved on this page. You can return to this page at any time to access this info.

 

Step 2: Provide the application ID in your app

  1. In Visual Studio, in Solution Explorer, right-click the Package.appxmanifest file and select View Code to open the app manifest file in XML view.

  2. In the mp:PhoneIdentity element, which is a child of the Package element, replace the GUID value of the PhoneProductID attribute with the Map service ApplicationID for your app.

Step 3: Provide the authentication token in your app

  1. If you're using the MapControl, provide the Map service AuthenticationToken as the value of the control's MapServiceToken property in your XAML markup or in your code, as appropriate.

    • In your XAML markup:

              <Maps:MapControl
                  x:Name="MapControl1"
                  MapServiceToken="abcdef-abcdefghijklmno" />
      
    • In your code:

          MapControl1.MapServiceToken = "abcdef-abcdefghijklmno";
      
  2. If you're using the methods of the Windows.Services.Maps namespace, provide the Map service AuthenticationToken as the value of the ServiceToken property of the static MapService class. For example:

        MapService.ServiceToken = "abcdef-abcdefghijklmno";