electron-vue-google-auth2

1.0.9 • Public • Published

electron-vue-google-auth

Library that manages Google OAuth2 authentication for your Electronvue app.

Install

// npm
$ npm install --save electron-vue-google-auth2


## Usage

### Access Token
```typescript
import ElectronVueGoogleOAuth2 from 'electron-vue-google-auth2';

app.on('ready', () => {
  const myApiOauth = new ElectronVueGoogleOAuth2(
    'CLIENT_ID',
    'CLIENT_SECRET',
    ['https://www.googleapis.com/auth/userinfo.email','https://www.googleapis.com/auth/userinfo.profile'],
    'SuccessRedirectUrl'
  );

  myApiOauth.openAuthWindowAndGetTokens()
    .then(token => {
      // use your token.access_token
    });
});

Refresh Token

import ElectronVueGoogleOAuth2 from 'electron-vue-google-auth2';

app.on('ready', () => {
  const myApiOauth = new ElectronVueGoogleOAuth2(
    'CLIENT_ID',
    'CLIENT_SECRET',
    ['https://www.googleapis.com/auth/userinfo.email','https://www.googleapis.com/auth/userinfo.profile'],
    'SuccessRedirectUrl'
  );
  
  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

Package Sidebar

Install

npm i electron-vue-google-auth2

Weekly Downloads

0

Version

1.0.9

License

MIT

Unpacked Size

16.4 kB

Total Files

11

Last publish

Collaborators

  • vishnug5621