Setting up an authentication for your client

Table of contents

  1. Description
  2. @Example - basic authentication
  3. @Example - oauth authentication

Description

In this example you will get familiar on how to setup an authentication object for your Alert Notification service client. The setup is nothing more than just providing the authentication object of your choice as an argument to your client instance’s constructor

@Example - basic authentication

You must replace username, password and region with ones specific for you.

import {
    AlertNotificationClient,
    BasicAuthentication,
    RegionUtils
} from '@sap_oss/alert-notification-client';

const client = new AlertNotificationClient({
    authentication: new BasicAuthentication({
        username: '<your-technical-client-username>',
        password: '<your-technical-client-password'
    }),
    region: RegionUtils.EU10;
});

// If you have setup correct credentials for your authentication you
// will be able to access the endpoints to which your technical client has scopes to

@Example - oauth authentication

You must replace username, password, oAuthTokenUrl and region with ones specific for you.

import {
    AlertNotificationClient,
    OAuthAuthentication,
    RegionUtils
} from '@sap_oss/alert-notification-client';

const client = new AlertNotificationClient({
    authentication: new OAuthAuthentication({
        username: '<your-technical-client-username>',
        password: '<your-technical-client-password',
        oAuthTokenUrl: '<oauth-token-url>'
    }),
    region: RegionUtils.EU10;
});

// If you have setup correct credentials for your authentication you
// will be able to access the endpoints to which your technical client has scopes to