Skip to content

Client-side javascript SDK for the IBM Cloud App ID service

License

Notifications You must be signed in to change notification settings

ibm-cloud-security/appid-clientsdk-js

Repository files navigation

IBM Cloud powered Coveralls Version DownloadsMonthly DownloadsTotal License

GithubWatch GithubStars GithubForks

IBM Cloud App ID JavaScript SDK

Client-side javascript SDK for the IBM Cloud App ID service to use with single-page applications created in Angular, React, or other frontend frameworks. Read the documentation for information on getting started with IBM Cloud App ID and single-page applications. Apps using Node.js should use our server-side SDK.

Table of Contents

Installation

Using npm:

npm install ibmcloud-appid-js
import AppID from 'ibmcloud-appid-js';

From the CDN:

<script src="https://cdn.appid.cloud.ibm.com/appid-1.0.1.min.js"></script>

Or for development purposes use the minified file in this repo:

<script type='text/javascript' src="dist/appid.min.js"></script>

Getting Started

A sample application can be found in the sample folder in this repo.

You will need an IBM Cloud App ID instance with a singlepageapp application created. Apps using Angular, React, or other frontend frameworks will require a specific type of credentials to use with IBM Cloud App ID. Visit the docs to learn more about creating application credentials.

Use the clientId and discoveryEndpoint from the application credentials to initialize the AppID instance.

const appID = new AppID();
await appID.init({
    clientId: '<SPA_CLIENT_ID>',
    discoveryEndpoint: '<WELL_KNOWN_ENDPOINT>'
});

Using the signin() in your app to start authentication:

document.getElementById('login').addEventListener('click', async () => {
    try {
        const tokens = await appID.signin();
    } catch (e) {
        ...
    }
});

Read the documentation for information about getting started with IBM Cloud App ID Service.

API Reference

Checkout our API reference here.

About

Client-side javascript SDK for the IBM Cloud App ID service

Resources

License

Stars

Watchers

Forks

Packages

No packages published