Javascript library, meant for browser use, to authenticate and authorize users against Björn Lundén Information


stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
12May 9, 2021Mar 26, 2018Minified + gzip package size for @blinfo/authjs in KB


Blinfo Authjs

A javascript library, meant for browser use, to authenticate and authorize users against Björn Lundén Information.


npm install @blinfo/authjs

For vanilla javascript projects

Load script

<script src="blauth-min.js" type="text/javascript"></script>


BLAuth.init({ clientId: 'your-client-id', redirectURI: 'your-redirect-url', scopes: ['requested-scope']});
BLAuth.getLoginStatus((res) => {
    console.log('Logged in user:' + res.name);

Init option params

  • clientId: string - The id of registrated client at BL.
  • redirectURI: string - Registrated redirect URL.
  • scopes: stringarray (optional) - Requested scopes. If no scope is provided, then the id scope USER_IDENTITY will be used.
  • returnURL: string (optional) - Return URL.
  • width: number (optional) - Width of login popup.
  • height: number (optional) - Height of login popup.
  • env: string (optional) - Environment (dev, test or empty for production).


BLAuth.login((res) => {
    console.log('Logged in user:' + res.name);


export interface BLUser {
    name: string;
    firstName: string;
    lastName: string;
    email: string;
    userName: string;
    authToken: string;


BLAuth.logout(res => {
    console.log("User logged out");

For Angular projects

Create a service and make sure the service is loaded at the redirect url.

import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Observable } from 'rxjs/Observable';
import * as blauth from '@blinfo/authjs';

export class Auth2Service {

    private _authState: BehaviorSubject<blauth.BLUser> = new BehaviorSubject(null);

    get authState(): Observable<blauth.BLUser> {
        return this._authState.asObservable();
    constructor() {
        blauth.init({ clientId: 'your-client-id', redirectURI: 'your-redirect-url', scope: 'requested-scope' });
        blauth.getLoginStatus((user: blauth.BLUser) => {

    login() {
        blauth.login((user: blauth.BLUser) => {
    logout() {
        blauth.logout(() => {

How to build and publish

  1. Clone repo.
  2. Make changes.
  3. Build.
    npm run build
  4. Commit changes.
    git add .
    git commit -m"made some changes."
  5. Update version by typing the command:
    npm version [major|minor|patch]
  6. Publish to npm registry.
    npm login
    npm publish
  7. Push commits AND tag to git.
    git push
    git push origin vX.X.X
    Need more help? https://docs.npmjs.com/getting-started/publishing-npm-packages

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.