electron-vue-google-auth2
v1.0.9
Published
Library that manages Google OAuth2 authentication for your Electron-vue app.
Downloads
4
Maintainers
Readme
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