bsso
v1.0.0
Published
Bloomberg SSO js utilities
Downloads
80
Readme
Bloomberg SSO js utilities
Install
yarn add bsso
! Usage with react native !
First setup react-native-get-random-values and react-native-webview-crypto and react-native-url-polyfill and text-encoding.
Simple Usage
import { BSSO } from 'bsso';
const bsso = new BSSO({
clientId: 'se-mobile-app',
redirectUri: 'http://localhost:8080/'
});
const tokenFromRedirectUrl = new URLSearchParams(window.location.hash).get('#token');
if (tokenFromRedirectUrl) {
// if we have #token, we are ready for redirect
console.log('redirect');
window.location.replace(await bsso.getRedirectURL(tokenFromRedirectUrl));
} else {
const code = new URLSearchParams(window.location.search).get("code");
if (code) {
// if we have the code, we are ready to continue getting token for authorization
const activeToken = await bsso.getToken(code);
console.log('activeToken', activeToken);
}
}
BSSO API
| Method | Arguments | Return | |----------------|-------------------------------|---------| | getToken | code?: string | string | | isExpired | | boolean | | getRedirectURL | token: string, scope?: string | string | | toJSON | | object |