Document toolboxDocument toolbox

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.

ParameterDescriptionDefaultRequired
configSee configuration parameters x

BID.doConnect ( callback(err, data), [config{..}, inlineOnLoadCallback, inlineModalWindow, inlineElementID] )

Starts OIDC login session with the given configuration set with doInit().

ParameterDescriptionDefaultRequired
callback

Function to handle response from Authorize call.

Arguments are:

  • err - error messages, if any
  • data - returned object with accessToken
 x
configConfig parameters can be provided which will override session parameters for this session only.
{}
 
inlineOnLoadCallbackCalled onload for injected iframe
null 
 

inlineModalWindow

Set to true to activate special inline login modal window.

Only active when used with inline integration method.

false
 
inlineElementIDID of DOM element to inject OIDC login iframe into. Required when using inline method.
null
 

BID.doGetUserInfo ( callback(err, user), [accessToken, tokenType, responseType] )

ParameterDescriptionDefaultRequired
callback

Function to handle response from userinfo call.

Arguments are:

  • err - error messages, if any
  • user - user object with data
 x
accessTokenOptionally provide own accessToken.
null
 
tokenTypeOptionally provide own tokenType.
null
 
responseTypeSet 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()

ParameterDescriptionDefault
client_idA 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'
methodThe chosen BankID OIDC Connect integration method, explained here.
'redirect'
response_type

The chosen authentication response type, explained here.

Ex. 'code', 'token', 'id_token'

'code'
response_mode

Set the format used when returning parameters from the Authorization Endpoint via redirect_uri

'query'
token_endpointAbsolute 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_endpointAbsolute URL to HTTP endpoint on merchant server-side to retrieve user information using access token.
'/oauth/userinfo'
redirect_uriHTTP(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 OIDC, ????, BIM or (empty).

Set user info such as NNIN or phone number / birthdate if required for step-up to the BankID IDP.

'OIDC'
stateIncrease security towards cross-site request forgery by verifying this value in the requests and responses
'untouched'
nonceProvide a nonce value for securing the integrity of the id_token 
grant_typeThis 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

NameDescription
bid-connector-loadedTriggered on document.body element when BankID OIDC Connect is loaded and ready to receive API calls

XDM Events for redirect_uri communication

NameDescription
bid-connector-response-dataAuthentication success, returns an Object with the authentication response data given.
bid-connector-errorAuthentication error, returns an Object with error information.