1.0.3 • Published 4 years ago

electron-vue-google-auth v1.0.3

Weekly downloads
3
License
MIT
Repository
-
Last release
4 years ago

electron-vue-google-auth

Library that manages Google OAuth2 authentication for your Electronvue app.

Install

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


## Usage

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

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

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

Refresh Token

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

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