项目作者: marckraw

项目描述 :
Electron helper for OAuth authorization to Github using web application flow strategy.
高级语言: JavaScript
项目地址: git://github.com/marckraw/electron-oauth-github.git
创建时间: 2020-12-28T15:50:06Z
项目社区:https://github.com/marckraw/electron-oauth-github

开源协议:MIT License

下载


Electron OAuth Github package.

How to use it ?

This package, helps with OAuth authorization from Github. It uses web application flow described here: @latest/developers/apps/authorizing-oauth-apps#web-application-flow"">https://docs.github.com/en/free-pro-team@latest/developers/apps/authorizing-oauth-apps#web-application-flow

Package is exposing 2 functions:

  1. module.exports = {
  2. getAuthorizationCode,
  3. getAccessToken
  4. }

To obtain Access Token, (which is the reason of this package), you need to use only getAccessToken
function. This function uses getAuthorizationCode underneath. When you obtain access token, you can than make request to Github Rest API with it.

  1. npm install @electron-utils/electron-oauth-github
  1. yarn add @electron-utils/electron-oauth-github
  1. const {getAccessToken} = require('@electron-utils/electron-oauth-github')
  2. try {
  3. const {access_token} = await getAccessToken({
  4. clientId: "your github app client id",
  5. clientSecret: "your github app client secret",
  6. redirectUri: "your rediretion uri",
  7. scope: "scope of permissions you want to give"
  8. })
  9. mainWindow.webContents.send('accessToken', access_token) // here, we just send access token to frontend part of electron app (to mainWindow)
  10. } catch (error) {
  11. console.log("error happened")
  12. console.log(error)
  13. }

Development

  1. git clone git@github.com:marckraw/electron-oauth-github.git
  1. yarn link

To use dev version, with you Electron application.

Build and deploy

There is no, build / bundling process for it, for now. When merged to master via PR, github action is fired, which
deploy package to npm global registry.

Is it production ready?

You should consider this as a testing/preview package. I needed this for my personal projects, so i’ve built it and publish it :)
If there will be enough interest in it, we can try to make it fully legit. Feel free to create issues, and also pull request.