Skip to main content

Osano's Unified Consent Javascript SDK

Osano's Unified Consent JavaScript SDK

Getting started

Getting an access token

In order to talk to our API you will need an access token. The issuer, configId, customerId, and the returned token are not sensitive. The token can be generated by, or passed along to the client application.

import { UnifiedConsentByOsanoSDK } from '@unifiedconsentbyosano/cmp-javascript-sdk'

const accessToken = await UnifiedConsentByOsanoSDK.getToken(
{
/** URL of authorization services provider */
issuer: string,
/** The config Id */
configId: string,
/** The Client Id */
customerId: string
},
)

The UnifiedConsentByOsanoClient can be used from a browser or node environment. You need an access token to instantiate it.

import { UnifiedConsentByOsanoSDK, Subject, ActionType } from '@unifiedconsentbyosano/cmp-javascript-sdk'

const client = UnifiedConsentByOsanoSDK.createClient({
token: accessToken,
apiUrl: 'https://uc.api.osano.com',
})

// Example with anonymous Subject
await client.createConsent({
tags: ['marvel', 'movies'],
actions: [{ target: 'navigation-system', vendor: 'general-vendor', action: ActionType.Accept }]
attributes: [{platform: 'Linux x86_64'}],
subject: Subject.verified('a-unique-id-of-this-subject')
})