Skip to content

Commit

Permalink
add document
Browse files Browse the repository at this point in the history
  • Loading branch information
mironal committed Dec 10, 2017
1 parent a3d9601 commit 31cf3aa
Show file tree
Hide file tree
Showing 52 changed files with 145,112 additions and 7 deletions.
41 changes: 36 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@

Easy to use helper library for OAuth1 and OAuth2.

This automatically manages the Electron window for OAuth.
All grant type supported.

- Authorization Code Grant
- Implicit Grant
- Resource Owner Password Credentials Grant
- Client Credentials Grant

> TODO: Refreshing an Access Token
You can get a token just by calling a method of start OAuth.

Expand All @@ -28,9 +35,19 @@ This library is lightweight because it depends only on [debug](https://github.co

const { OAuth1Provider } = require("electron-oauth-helper")

const window = new BrowserWindow({
width: 600,
height: 800,
webPreferences: {
nodeIntegration: false // We recommend disabling nodeIntegration for security.
contextIsolation: true // We recommend enabling contextIsolation for security.
// see https://github.com/electron/electron/blob/master/docs/tutorial/security.md
},
})

const config = { /* oauth config. please see example/main/config.example.js. */}
const provider = new OAuth1Provider(config)
provider.perform()
provider.perform(window)
.then(resp => {
console.log(resp)
})
Expand All @@ -43,9 +60,23 @@ provider.perform()

const { OAuth2Provider } = require("electron-oauth-helper")

const window = new BrowserWindow({
width: 600,
height: 800,
webPreferences: {
nodeIntegration: false // We recommend disabling nodeIntegration for security.
contextIsolation: true // We recommend enabling contextIsolation for security.
// see https://github.com/electron/electron/blob/master/docs/tutorial/security.md
},
})

const config = { /* oauth config. please see example/main/config.example.js. */}
const provider = new OAuth2Provider(config).withCustomAuthPrameter({}).withCustomTokenParameter({})
provider.perform()
const provider = new OAuth2Provider(config)
// Your can use custom parameter.
// const provider = new OAuth2Provider(config)
// .withCustomAuthorizationRequestParameter({})
// .withCustomAccessTokenRequestParameter({})
provider.perform(window)
.then(resp => {
console.log(resp)
})
Expand All @@ -70,7 +101,7 @@ const { OAuth2Provider } = require("electron-oauth-helper")

const config = { /* oauth config. please see example/main/config.example.js. */}
const provider = new OAuth2Provider(config)
provider.perform()
provider.perform(window)
.then(resp => {
const query = querystring.parse(resp)
const credential = firebase.auth.GithubAuthProvider.credential(query.access_token)
Expand Down
Loading

0 comments on commit 31cf3aa

Please sign in to comment.