@8base/web-oauth-client 中文文档教程
8base api token auth client
AuthProvider
的 8base web oauth 客户端。
WebOAuthClient
Table of Contents
WebOAuthClient
创建 Web oauth 客户端的实例
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
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 = '/';
}
});