Nine Pounds of Mayonnaise

    @getstation/electron-google-oauth2
    TypeScript icon, indicating that this package has built-in type declarations

    2.1.0 • Public • Published

    @getstation/electron-google-oauth2

    Library that manages Google OAuth2 authentication for your Electron app.

    Install

    // npm
    $ npm install --save @getstation/electron-google-oauth2
    // yarn
    $ yarn add @getstation/electron-google-oauth2
    

    Usage

    Access Token

    import ElectronGoogleOAuth2 from '@getstation/electron-google-oauth2';
    
    app.on('ready', () => {
      const myApiOauth = new ElectronGoogleOAuth2(
        'CLIENT_ID',
        'CLIENT_SECRET',
        ['https://www.googleapis.com/auth/drive.metadata.readonly']
      );
    
      myApiOauth.openAuthWindowAndGetTokens()
        .then(token => {
          // use your token.access_token
        });
    });

    Refresh Token

    import ElectronGoogleOAuth2 from '@getstation/electron-google-oauth2';
    
    app.on('ready', () => {
      const myApiOauth = new ElectronGoogleOAuth2(
        'CLIENT_ID',
        'CLIENT_SECRET',
        ['https://www.googleapis.com/auth/drive.metadata.readonly']
      );
      
      const refreshToken = \\ Read the saved refresh token
      
      if(refreshToken) {
        myApiOauth.SetTokens({ refresh_token: refreshToken });
      } else {
        myApiOauth.openAuthWindowAndGetTokens()
          .then(token => {
            // save the token.refresh_token secured to use it the next time the app loading
            // use your token.access_token
          });
      }
    });

    License

    MIT

    Install

    npm i @getstation/electron-google-oauth2

    DownloadsWeekly Downloads

    231

    Version

    2.1.0

    License

    MIT

    Unpacked Size

    17.9 kB

    Total Files

    11

    Last publish

    Collaborators

    • jeremy_vincent
    • v1s10n_4
    • matthd
    • nacryn
    • trapcodien
    • magne4000