Cvmcosta / ltijs

Turn your application into a fully integratable LTI 1.3 tool provider.
https://cvmcosta.github.io/ltijs/
Apache License 2.0
299 stars 67 forks source link

{"status":401,"error":"Unauthorized","details":{"description":"No Ltik or ID Token found.","message":"NO_LTIK_OR_IDTOKEN_FOUND","bodyReceived":{}}} #169

Open sunilkatkar-adeptus opened 1 year ago

sunilkatkar-adeptus commented 1 year ago

@Cvmcosta I am new to LTIJS integration. Actually I am trying to create LTI 1.3 tool for coursera LMS using sample code provided by you.

But when I try to launch tool from coursera its showing me "{"status":401,"error":"Unauthorized","details":{"description":"No Ltik or ID Token found.","message":"NO_LTIK_OR_IDTOKEN_FOUND","bodyReceived":{}}}" this error.

Below is index.js that am using,

require('dotenv').config(); const path = require('path'); const routes = require('./src/routes'); const lti = require('ltijs').Provider;

let consumerAccessTokenURL = "https://api.coursera.org/api/lti/auth/accessToken/1220~sharedsuccessorg"; let consumerAuthorizationURL = "https://api.coursera.org/api/lti/auth/token"; let consumerToolClientID = "4G4uXxHdSqauLl8R3WqmXw" ; let consumerName = "coursera"; let consumerUrl = "https://coursera.org"; let consumerAuthorizationconfig = { method: "JWK_SET", key: "https://api.coursera.org/api/lti/keyset" };

const LTI-key = "li737drHRR+O2MLCmur0nHahZ0Z2kBP10HAKRUm39NIrKummL3Ja4xzDZIX1JltP";

lti.setup(LTI-key, { url: process.env.DB_HOST + '/' + process.env.DB_NAME, connection: { user: process.env.DB_USER, pass: process.env.DB_PASS } }, { // Options appRoute: '/', loginRoute: '/login', // Optionally, specify some of the reserved routes cookies: { secure: false, // Set secure to true if the testing platform is in a different domain and https is being used sameSite: '' // Set sameSite to 'None' if the testing platform is in a different domain and https is being used }, devMode: true } )

// Setting up routes //lti.app.use(routes)

const setup = async () => { lti.appUrl('/'); lti.loginUrl('/login'); await lti.deploy({port: 3000}); lti.whitelist(lti.appRoute(), { route: '/', method: 'get' }) let platform = await lti.registerPlatform({ url: consumerUrl, name: consumerName, clientId: consumerToolClientID, authenticationEndpoint: consumerAuthorizationURL, accesstokenEndpoint: consumerAccessTokenURL, authConfig: consumerAuthorizationconfig }) //console.log('the platform after the set is', platform); const key = await platform.platformPublicKey() // console.log('key',key) // Set connection callback lti.onConnect((connection, request, response) => { // Call redirect function lti.redirect(response, '/main') })

// Set route accounting for issuer context lti.app.get('/:iss/main', (req, res) => { // Id token console.log(res.locals.token) res.send('It\'s alive!') }) console.log("Outside onConnect"); } setup(); module.exports = lti.app;

Please find attachment for launch, auth & redirect url setting. Can you please help me out exactly where am going wrong.

image image

sunilkatkar-adeptus commented 1 year ago

@Cvmcosta After launch onConnect callback is not invoking

Ebcosio commented 8 months ago

I have this same problem (or at least the same error message) when trying to set this up with a local Canvas LMS instance, using the QuickStart code.

{"status":401,"error":"Unauthorized","details":{"description":"No Ltik or ID Token found.","message":"NO_LTIK_OR_IDTOKEN_FOUND","bodyReceived":{"iss":"https://canvas.instructure.com","login_hint":"b93c9bfffd4cb29371de1bc257d3a8d87fede7f4","client_id":"10000000000001","deployment_id":"1:d28a6eb2db6c3908d7bf74a38069c0036813d089","target_link_uri":"http://localhost:3000/","lti_message_hint":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2ZXJpZmllciI6IjNiY2VmYWM0NWNhZWQ2ZWE2ZTc4NDAzYmEwM2M1YzhhODUyMzRiYmI5ZWE1OTcyMjkzNWU3ZmUwMDQ0OTZhNTdlODRkNThlMTgwM2NiNjEyM2U0Yjk0YWEwNzkwYThiNmUxYWVhYThhODNmOTBjMzAzODRiMTRjNzU1M2YyNjA5IiwiY2FudmFzX2RvbWFpbiI6IjE5Mi4xNjguMC45MyIsImNvbnRleHRfdHlwZSI6IkNvdXJzZSIsImNvbnRleHRfaWQiOjEwMDAwMDAwMDAwMDAxLCJjYW52YXNfbG9jYWxlIjoiZW4iLCJpbmNsdWRlX3N0b3JhZ2VfdGFyZ2V0Ijp0cnVlLCJleHAiOjE3MDQ1NjQ3NTB9.bHJIB2GgXJniYqoXBdpdPPVhT8-7mtOkdNm7Zpn4EwY","canvas_environment":"prod","canvas_region":"not_configured","lti_storage_target":"_parent"}}}

@sunilkatkar-adeptus were you able to resolve this?