Skip to content

Latest commit

 

History

History

javascript

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

BankID NodeJS implicit grant flow example

This is an example of using BankID with client-side JavaScript and OIDC Implicit Flow.

In this example we first login using OIDC Implicit Flow which is Connect product usage and then fetch /userinfo EndPoint which simulates using the Identify product.

Since OpenID Connect uses redirects, you will need a development server to try this example. We use serve for NodeJS, but you can use what you are most familiar with (just make sure to update redirect_uri accordingly).

Running the example

Structure

Client configuration is mainly client_id which is provided to you through the BankID developer portal. scopes parameter specifies which data is requested from the end-user. When you are ready to go into production, update authEndpoint and userInfoEndpoint URLs according to documentation.

// BankID sandbox auth endpoint
const authEndpoint = 'https://oidc.sandbox.bankid.cz/auth';

// Set Userinfo / Profile URL
const userInfoEndpoint = 'https://oidc.sandbox.bankid.cz/userinfo';

// Configuration of scopes from BankID dev portal
const scopes = ['openid', 'profile.email'];

// Query parameters for the auth call
const authUriParams = {
  client_id: '0c53196f-fdba-4d27-84c0-a74e00e775b6',
  state: 'Optional state value you want to pass on',
  scope: scopes.join(' '),
  // Redirect URI to your application
  redirect_uri: 'http://localhost:5000',
  // reponse_type 'token' for implicit flow
  response_type: 'token',
};