accountsSDK
accountsSDK
is a small library that installs the "Sign in with LiveChat" button on any website or app. It also wraps OAuth flow in an easy-to-use API.
Installation
npm install --save @livechat/accounts-sdk
Button
Example sign in with LiveChat button desigs. Assets are available here.
Usage
import { AccountsSDK } from '@livechat/accounts-sdk';
// create new SDK instance with it's options
const sdk = new AccountsSDK({
client_id: '<your_app_client_id>'
});
// use one of available methods to authorize a user
// popup (must be run in an event hadler to avoid the popup beeing blocked)
sdk.popup().authorize((err, authorizeData) => {
})
// browser redirect
sdk.redirect().authorize()
// iframe redirect, not recommended
sdk.iframe().authorize((err, authorizeData) => {
})
Options
client_id
string required registered client IDprompt
string use consent
to force consent prompt in a popup and redirect flowsresponse_type='token'
string OAuth response type, use token
or code
popup_flow='auto'
string auto
- don't show popup when credentials are not required, manual
- always show popupstate
string OAuth state param, auto generated by SDK when emptyverify_state=true
bool a function that returns transaction should verify if the state matchesscope
string - custom scope list, must be a subset of preconfigured client ID scopesredirect_uri
string OAuth redirect URI - current location by defaultemail_hint
string fill in an email hint in formsserver_url='https://accounts.livechat.com'
string authorization server urltracking
object tracking querystring paramstransaction.namespace='com.livechat.accounts'
string transaction keys prefixtransaction.key_length=32
number transaction random state lengthtransaction.force_local_storage=false
bool try to use local storage instead of cookiespkce.enabled=true
bool Oauth 2.1 PKCE extension enabled for code
grantpkce.code_verifier
string override auto generated code verifierpkce.code_verifier_length=128
number code verifier length, between 43 and 128 characters https://tools.ietf.org/html/rfc7636#section-4.1pkce.code_challange_method='S256'
string code challange method, use S256
or plain