Mo authentication library


1.0.12-alpha.05 months ago4 years agoMinified + gzip package size for @mo-platform/auth in KB


JS client for MoAuth

MoAuth provides an OAuth proxy to various providers. For the time being it only supports Fagbokforlaget e-portal or FEIDE. This js library provides necessary abstraction for authentication from various services.

NOTE: Mo-Auth lib replies on modern browsers and does not includes polyfills for fetch and Promise. You may include them yourself and if you use it inside vue then edit vue.config.js and add transpileDependencies:['@mo-platform/auth']. Also vuejs automatically insers es-promise polyfill but you still have to add polyfill for fetch. We recommend using import whatwg-fetch in your main.js.


npm install @mo-platform/auth


import MoAuth from '@mo-platform/auth'
let auth = new MoAuth()
// do something with auth

Install browser method

// Include polyfills if desired
<script crossorigin="anonymous" src="https://polyfill.io/v3/polyfill.min.js?features=fetch%2Ces2017"></script>

let auth = new moauth()

// initate oauth workflow
auth.authorize({redirectUrl: 'http://locahost:8000', scope: 'mo_apps'}); // url redirect (optional)

// listen to access token in url query
.then(user) {
  //do something with user
.catch(err) {

// To check product access
  .then((user) => {
    // Do something
    return auth.checkAccess(['product1'])
  .then((resp) => {
    if (resp.products.includes('product1)) {
      // Success
    else {
      // failure
  .catch((err) => {
    // Handle error

// async await

const user = await auth.checkToken()
const resp = await auth.checkAccess(['product1'])

if (resp.products.includes('product1') {
  // success
else {
  // failure

// clears localstorage for access token

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.