-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
49 lines (39 loc) · 1.06 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const express = require('express')
const dotenv = require('dotenv')
const path = require('path')
const fs = require('fs')
const dotenvFilePath = path.resolve(__dirname, `./.env`)
const passgate = require('./example/passgate')
if (fs.existsSync(dotenvFilePath)) {
dotenv.config({
path: dotenvFilePath,
encoding: 'utf8'
})
}
const app = express()
const port = process.env.PORT || 3000
app.get('/google171ccb7b0cbbac7a.html', function(req, res) {
res.sendFile(path.join(__dirname + '/google171ccb7b0cbbac7a.html'))
})
app.use(passgate)
app.get('/', async (req, res) => {
const {google} = req.passgate
const client = google.getClient()
client.setCredentials({
access_token: '',
refresh_token: ''
})
try {
google.instance.options({auth: client})
const oauth2 = google.instance.oauth2({
auth: client,
version: 'v2'
})
const res = await oauth2.userinfo.get()
console.log(res)
} catch (err) {
console.log(err)
}
res.send('Hello World!')
})
app.listen(port, () => console.log(`Passgate running on ${port}!`))