1. Help Centre
  2. 1map Embeddable Viewer

How to get your Token to access the Web Viewer

The embeddable web viewer requires a token to be passed through to get access to the layers. This article explains how to get the Token.

Your 1map username and password is used to obtain a token that should be passed as a URL parameter to the online Viewer.

Make sure to get your token in the back end as not to expose your username and password in the front end!!

Here is sample code for retrieving your token (Adjust to the back-end language that you are using.):

var 1mapUsername = "map_viewer@1map.co.za";
var 1mapPassword = "map_viewer98";
var token = "";

var jqxhr = $.ajax({
type: "GET",
url: "https://www.1map.co.za/api/v1/auth/login/",
dataType: "json",
timeout: 60000 * 2, // 2 minutes
data: {
email: TEMPmapUsername,
password: TEMPmapPassword,
},
error: function (xhr, status, error) {
// alert(error);
},
success: function (response) {
if (response && response.result) {
token = response.apiToken.token;
if (response.result.maprestriction) {
maprestriction = response.result.maprestriction;
}
}
},
async: false,
});