How to access /use a secured layer using my token?

How to access /use a secured layer using my token?

You can access any secured layer using your token depending on your preference using one of the below methods:
· QGIS

◦ From data source manager, add a new connection

◦ Enter connection name

◦ Enter layer URL you have from the secured links at MnA guardian edition

◦ From the authentication section, create a new authentication profile

◦ Enter profile name

◦ Change authentication type to “OAuth2 authentication”

◦ In the configure tab, change grant flow to “Resource owner”

◦ Enter token URL, for example: “${keycloakurl}/realms/${organizationName}/protocol/openid-connect/token”

◦ Enter client ID

◦ Enter client secret

◦ Provide credentials “username & password”

◦ Enter scope as “openid”

◦ In the advanced section below, change access method to “Header”

◦ Now save and connect, you should be able to list all your permitted layers
ArcGIS Desktop (ArcMap10.3)

◦ From the catalog, navigate to GIS servers

◦ Add a new connection (WMS server)

◦ In the URL, add the URL you have from the secured links at MnA guardian edition, the URL should be constructed as the follow: “http://guardianURL/wmsCapability/$Error! Hyperlink reference not valid.

◦ Now you should be able to list all your permitted layers
· WebApps based on OpenLayers

Create a new Image object following the below example:

import Image from 'ol/layer/Image';

let myImage = new Image(

{

title: layerTitle,

source: new ImageWMS(

{

url: layerURL,

params: {

[LAYERS],

VERSION: '1.1.1'

},

imageLoadFunction: function customLoader(tile, src) {

axios.get(src, {

headers: {

Authorization: 'Bearer ' + token,

PentaOrgID: tokenInfo.user.split('@')[1],

PentaSelectedLocale: ${locale},

PentaUserRole: ${role}

},

responseType: 'arraybuffer'

})

.then(({ data, _ }) => {

const base64 = btoa(

new Uint8Array(data).reduce(

(d, byte) => d + String.fromCharCode(byte),

'',

),

);

tile.getImage().src = 'data:image/png;base64,' + base64;

}).catch(e => {

tile.getImage().dispatchEvent(new Event('error'));

})

}

}

)

}

)
    • Related Articles

    • Obtain an access token

      Before your application can access private data using Penta-b API, it must obtain an access token that grants access to that API. A single access token can grant varying degrees of access to multiple APIs. There are several ways to make a token ...
    • Refresh the access token

      Access tokens have limited lifetimes. If your application needs access to a Penta-b’s API beyond the lifetime of a single access token, it can obtain a refresh token. A refresh token allows your application to obtain new access tokens
    • Testing obtaining access tokens

      After receiving the OAuth 2.0 credentials, the configurations can be checked easily using Postman. Here is how: Open a new Postman request. Navigate to the Authorization tab, and select OAuth 2.0 from TYPE 3. Click on Get New Access Token button 4. ...
    • Send the access token to an API

      After the application obtains an access token, it should send the token to a Penta-b’s API in an HTTP Authorization request header. The following headers should be added to each request: PentaUserRole: the selected user’s role PentaOrgID: the ...
    • MnA OGC secured links for your layers

      After on-boarding a new layer you can get OGC secured links for your layers for each role that can work on QGIS desktop client, ArcGIS desktop client and your customized developed mobile and web application or any other OGC compliant client. 1- ...