https://github.com/alvarolorentedev/oauth-electron
General OAuth support for electron App.
https://github.com/alvarolorentedev/oauth-electron
authentication authorization electron oauth
Last synced: 10 months ago
JSON representation
General OAuth support for electron App.
- Host: GitHub
- URL: https://github.com/alvarolorentedev/oauth-electron
- Owner: alvarolorentedev
- License: mit
- Created: 2016-04-22T12:31:34.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2024-05-17T00:05:01.000Z (over 1 year ago)
- Last Synced: 2024-05-17T01:25:12.936Z (over 1 year ago)
- Topics: authentication, authorization, electron, oauth
- Language: JavaScript
- Homepage:
- Size: 1.38 MB
- Stars: 7
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# 
[](https://travis-ci.org/kanekotic/oauth-electron)
[](https://codecov.io/gh/kanekotic/oauth-electron)
[](https://github.com/kanekotic/oauth-electron)
[](https://github.com/kanekotic/oauth-electron/blob/master/LICENSE)
[](https://GitHub.com/kanekotic/oauth-electron/graphs/commit-activity)
[](https://www.paypal.me/kanekotic/)
Use OAuth in a simple way inside your electron App.
## Installation
add it to your electron project using `npm install oauth-electron --save` or `yarn add oauth-electron`
## Usage
require `oauth-electron` exports a function that requires a javascript object and an electron window, as seen on the next example:
### Oauth1
```js
const login = require(`oauth-electron`)
let info = {
key: ***,
secret: ***,
accessUrl: ***,
authenticateUrl: ***,
version: ***,
authCallback: ***,
signatureMethod: ***,
},
window = new BrowserWindow({webPreferences: {nodeIntegration: false}});
login.oauth1(info, window)
```
the login function will return a Promise with the access token and secret
```
{
token: ***,
tokenSecret: ***
}
```
### Oauth2
```js
const login = require('oauth-electron')
const { BrowserWindow, session } = require('electron')
let info = {
key: ***,
secret: ***,
scope: ***,
baseSite: ***,
authorizePath: ***,
accessTokenPath: ***,
redirectUrl: ***,
responseType: ***, //this is optional if not provided it will default to 'code'
},
window = new BrowserWindow({webPreferences: {nodeIntegration: false}});
login.oauth2(info, window, session)
```
the login function will return a Promise with the access token and secret
```
{
accessToken: ***,
refreshToken?: ***,
}
```
## Security
Consider this before you integrate this library in your application:
- It is a bad practice to hardcode `keys` & `secrets` in code that is going to be shipped.
- If you are looking to have your own backend, consider using it for authentication with 3rd party services. [IETF RFC 8252](https://tools.ietf.org/html/rfc8252).
## Migration V1.x to V2.x
- Please refer to the response of the service, as there will probably be extra fields in the response
- session is required to be passed as events of chromium have changed
## Migration V0.x to V1.x
- there is no more need for the oauth object, info becomes a basic object with the properties stated in the usage step.
- the return object has a different format.
###### logo: Award,Passport graphics by Freepik from Flaticon are licensed under CC BY 3.0. Made with Logo Maker