@lighthouseapps/oauth2-client
v1.0.10
Published
> Javascript oauth2 client
Downloads
7
Keywords
Readme
oauth2-client
Javascript oauth2 client
Usage
import OAuth2Client from './lib/OAuth2Client';
import AsyncStorage from '@react-native-community/async-storage';
class ReactNativeOAuth2Model {
constructor(navigation) {
this.navigation = navigation;
}
createCode() {}
createCodeToken() {}
createPasswordToken() {}
refreshToken() {}
signout() {}
}
class ReactNativeOAuth2 {
initialize(model, options = {}) {
this.client = new OAuth2Client(model, {
...options,
Storage: AsyncStorage
});
}
getToken() {
return this.client.getToken();
}
signinWithPassword() {
return this.client.signinWithPassword(...arguments);
}
signinWithAuthorizationCode() {
return this.client.signinWithAuthorizationCode(...arguments);
}
signout() {
return this.client.signout();
}
}
class WebOAuth2 {
initialize(model, options = {}) {
this.client = new OAuth2Client(model, {
...options,
Storage: localStorage
});
}
getToken() {
return this.client.getToken();
}
signinWithPassword() {
return this.client.signinWithPassword(...arguments);
}
signinWithAuthorizationCode() {
return this.client.signinWithAuthorizationCode(...arguments);
}
signout() {
return this.client.signout();
}
}
const oauth2 = new ReactNativeOAuth2();
oauth2.initialize(new ReactNativeOAuth2Model(this.props.navigation));