GithubHelp home page GithubHelp logo

arsalimam / oauth2-for-electron Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zicsus/oauth2-for-electron

0.0 1.0 1.0 20 KB

A super lightweight and simple OAuth2 utility for Electron.

JavaScript 100.00%

oauth2-for-electron's Introduction

oauth2-for-electron

What's this

A super lightweight and simple OAuth2 utility for Electron. Only Authorization Code Grant supported.

Usage

Install

npm install oauth2-for-electron

Uninstall

npm uninstall oauth2-for-electron

Config

const config = {
	auth_url: '', // URL to authorize endpoint. 
	token_url: '', // URL to token endpoint.
	client_id: '',
	client_secret: '',
	redirect_uri: '',
	scope: [], // All the required scopes in a array.
	scope_deliminator: '', // (OPTIONAL) This is use for joininig the scopes provided in scope array. default value ' '. 
	state: '' // (OPTIONAL) An unique value used by the client to maintain state between the request and callback.
};

Access Token

const OAuth2 = require('oauth2-for-electron');

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

const provider = new OAuth2(config);
provider.begin(win, (err, response) => 
{
	if(err)
	{
		// Something bad happened.
	}

	// Access token should be present in response.
});

Refresh Token

const OAuth2 = require('oauth2-for-electron');

const provider = new OAuth2(config);
provider.refreshToken(refresh_token)
.then(response => 
{
	// New access token.
})
.catch(err => 
{
	// Something bad happened.
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.