API Reference
The JS Connector consists of a 3 methods, 3 events and a set og configurations parameters are summarized below
Methods
The JS Connector consists of the following methods:
BID.doInit( config{...} )
Sets the configuration for the current session towards OIDC IDP.
Parameter | Description | Default | Required |
---|---|---|---|
config | See configuration parameters | x |
BID.doConnect ( callback(err, data), [config{..}, inlineOnLoadCallback, inlineModalWindow, inlineElementID] )
Starts OIDC login session with the given configuration set with doInit()
.
Parameter | Description | Default | Required |
---|---|---|---|
callback | Function to handle response from Authorize call. Arguments are:
| x | |
config | Config parameters can be provided which will override session parameters for this session only. | {} | |
inlineOnLoadCallback | Called onload for injected iframe | null | |
inlineModalWindow | Set to true to activate special inline login modal window. Only active when used with | false | |
inlineElementID | ID of DOM element to inject OIDC login iframe into. Required when using inline method. | null |
BID.doGetUserInfo ( callback(err, user), [accessToken, tokenType, responseType] )
Parameter | Description | Default | Required |
---|---|---|---|
callback | Function to handle response from userinfo call. Arguments are:
| x | |
accessToken | Optionally provide own accessToken. | null | |
tokenType | Optionally provide own tokenType. | null | |
responseType | Set to token if userInfo request should go directly to oauth endpoint instead of through the middleware. | 'code' |
Configuration
Configuration of the JS Connector is set by passing an object to BID.doInit() or the config parameter of BID.doConnect()
Parameter | Description | Default |
---|---|---|
client_id | A string specifying the client ID given when registering to the OIDC central service. | |
scope | A string of resource types (dataset) belonging to the user to request access to. Each scope / resource type must be separated by space. | 'openid' |
method | The chosen BankID OIDC Connect integration method, explained here. | 'redirect' |
response_type | The chosen authentication response type, explained here. Ex. | 'code' |
response_mode | Set the format used when returning parameters from the Authorization Endpoint via | 'query' |
token_endpoint | Absolute URL to HTTP endpoint on merchant server-side to retrieve access/ID token in exchange for authorization code (if using code response_type). | '/oauth/token' |
userinfo_endpoint | Absolute URL to HTTP endpoint on merchant server-side to retrieve user information using access token. | '/oauth/userinfo' |
redirect_uri | HTTP(S) endpoint receiving the authentication response from OIDC | |
oauth_url | Absolute URL to the OIDC OAUTH endpoint. Ex. https://oidc-preprod.bankidapis.no/oauth Likely never applicable to change. | (default OAUTH endpoint for the OIDC service) |
login_hint | Preset the OIDC client type, one of Set user info such as NNIN or phone number / birthdate if required for step-up to the BankID IDP. | 'OIDC' |
state | Increase security towards cross-site request forgery by verifying this value in the requests and responses | 'untouched' |
nonce | Provide a nonce value for securing the integrity of the id_token | |
grant_type | This field always contains the value authorization_code, as defined in the OAuth 2.0 specification. | 'authorization_code' |
Events
The following events are defined by the JS Connector
Event for loading JS Connector
Name | Description |
---|---|
bid-connector-loaded | Triggered on document.body element when BankID OIDC Connect is loaded and ready to receive API calls |
XDM Events for redirect_uri communication
Name | Description |
---|---|
bid-connector-response-data | Authentication success, returns an Object with the authentication response data given. |
bid-connector-error | Authentication error, returns an Object with error information. |