Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Commit

Permalink
Merge pull request #17 from johnf/master
Browse files Browse the repository at this point in the history
Add state support
  • Loading branch information
mawie81 authored Jul 12, 2017
2 parents 0fbf9db + 11eae1e commit 9ea2773
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ const nodeUrl = require('url');
const electron = require('electron');
const BrowserWindow = electron.BrowserWindow || electron.remote.BrowserWindow;

var generateRandomString = function (length) {
var text = '';
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

for (var i = 0; i < length; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}

return text;
};

module.exports = function (config, windowParams) {
function getAuthorizationCode(opts) {
opts = opts || {};
Expand All @@ -19,7 +30,8 @@ module.exports = function (config, windowParams) {
var urlParams = {
response_type: 'code',
redirect_uri: config.redirectUri,
client_id: config.clientId
client_id: config.clientId,
state: generateRandomString(16)
};

if (opts.scope) {
Expand Down

0 comments on commit 9ea2773

Please sign in to comment.