NASA Planetary Mission

    @lighthouseapps/oauth2-client

    1.0.10 • Public • Published

    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));

    Keywords

    none

    Install

    npm i @lighthouseapps/oauth2-client

    DownloadsWeekly Downloads

    5

    Version

    1.0.10

    License

    MIT

    Unpacked Size

    8.6 kB

    Total Files

    10

    Last publish

    Collaborators

    • leosampc
    • marlonconstante
    • gustavo-kuze
    • donnes
    • alvarosilveiraa
    • lhdev