@8base/web-oauth-client

The 8base web oauth client for the AuthProvider.

Usage no npm install needed!

<script type="module">
  import 8baseWebOauthClient from 'https://cdn.skypack.dev/@8base/web-oauth-client';
</script>

README

8base api token auth client

The 8base web oauth client for the AuthProvider.

WebOAuthClient

Table of Contents

WebOAuthClient

Create instance of the web oauth client

Parameters

  • authorize Function Function used to describe authorize logic.

Usage

Firebase oauth

import firebase from 'firebase';
import { WebOAuthClient } from '@8base/web-oauth-client';

const FIREBASE_CONFIGURATION = {
  apiKey: "",
  authDomain: "",
  databaseURL: "",
  projectId: "",
  storageBucket: "",
  messagingSenderId: "",
  appId: ""
};

const firebaseAuth = firebase.initializeApp(FIREBASE_CONFIGURATION).auth();

const authClient = new WebOAuthClient({
  authorize (email, password) {
    return firebaseAuth.signInWithEmailAndPassword(
      email,
      password,
    )
      .then(() => firebaseAuth.currentUser.getIdToken())
      .then((token) => {
        return token;
      })
    },
  logout() {
    window.addEventListener('unload', () => {
      this.purgeState();
    });

    window.location.href = '/';
  }
});

Examples

Firebase oauth example
IBM cloud oauth example