Skip to content
This repository has been archived by the owner on Sep 28, 2023. It is now read-only.

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgodhani committed Mar 7, 2021
1 parent dd77e9a commit 2f0909b
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,51 @@ if (!primaryInstance) {
app.quit()
} else {
app.on('second-instance', (event, argv, cmd) => {
log.info(argv)
event.preventDefault()
const url = argv[argv.length - 1]
if (win) {
if (win.isMinimized()) {
win.restore()
}
win.focus()
}
if (process.platform !== 'darwin') {
if (url.includes('ravenreader://inoreader/auth')) {
const q = new URL(url).searchParams
if (q.has('code')) {
axios.post('https://www.inoreader.com/oauth2/token', {
code: q.get('code'),
client_id: process.env.VUE_APP_INOREADER_CLIENT_ID,
client_secret: process.env.VUE_APP_INOREADER_CLIENT_SECRET,
redirect_uri: 'ravenreader://inoreader/auth',
scope: null,
grant_type: 'authorization_code'
}).then((data) => {
data.data.expires_in = dayjs().add(data.data.expires_in, 'second').valueOf()
win.webContents.send('inoreader-authenticated', data.data)
})
}
}
if (url === 'ravenreader://pocket/auth') {
axios
.post(
'https://getpocket.com/v3/oauth/authorize', {
consumer_key: consumerKey,
code: code
}, {
withCredentials: true,
headers: {
'Content-Type': 'application/json',
'X-Accept': 'application/json'
}
}
)
.then(data => {
data.data.consumer_key = consumerKey
win.webContents.send('pocket-authenticated', data.data)
})
}
}
})
}

Expand Down

0 comments on commit 2f0909b

Please sign in to comment.