-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnection.js
39 lines (32 loc) · 1.01 KB
/
connection.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
const path = require('path')
// Require Provider
const LTI = require('ltijs').Provider
// Configure provider
const lti = new LTI('EXAMPLEKEY',
{ url: 'mongodb://localhost/database' },
{ appUrl: '/', loginUrl: '/#', logger: true })
let setup = async () => {
// Deploy and open connection to the database
await lti.deploy({ port: 3000 })
// Register platform
let plat = await lti.registerPlatform({
url: 'https://platform.url',
name: 'Platform Name',
clientId: 'TOOLCLIENTID',
authenticationEndpoint: 'https://platform.url/auth',
accesstokenEndpoint: 'https://platform.url/token',
authConfig: { method: 'JWK_SET', key: 'https://platform.url/keyset' }
})
// Set connection callback
lti.onConnect((connection, request, response) => {
// Call redirect function
lti.redirect(response, '/main')
})
// Set main route
lti.app.get('/main', (req, res) => {
// Id token
console.log(res.locals.token)
res.send('It\'s alive!')
})
}
setup()