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. Since the client ID and client secret are required to issue a token, this call must be performed from a backend service.

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

const scopes = [Scopes.ConsentWrite]

const accessToken = await UnifiedConsentByOsanoSDK.getToken(
{
/** URL of authorization services provider */
issuer: string,
/** The config Id */
configId: string,
/** The Collection Id */
collectionId: 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')
})