How to get id user from encrypted user in idToken
See original GitHub issueDescribe the bug I’m trying to retrieve id user from token of lti.onConnect function. However, the token only returns the user with an encrypted value.
lti.onConnect((token, req, res) => {
logger.debug(res.locals.token);
if (token) {
return res.sendFile(path.join(__dirname, '../../public'));
} else {
lti.redirect(res, '/nolti');
} // Redirects to landing page
});
Response
{
iss: 'https://test.domain.com',
user: 'e26c4380-4d3c-45b9-94d6-b933322dd38a',
platformInfo: {
guid: 'OJwJhR6cNZVC9aiyUh8DLT9onnyVif2hOWpa5490:canvas-lms',
name: 'Root account',
version: 'cloud',
product_family_code: 'canvas',
validation_context: null
},
clientId: '10000000000015',
platformId: '7bbe71fdde1a2b80db7d76ebb068e4ad',
deploymentId: '63:89359961b094933bbad8477d368c335b99f84b79',
createdAt: '2020-12-30T03:06:52.073Z',
platformContext: {
roles: [
'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Administrator',
'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Instructor',
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
'http://purl.imsglobal.org/vocab/lis/v2/system/person#SysAdmin',
'http://purl.imsglobal.org/vocab/lis/v2/system/person#User',
[length]: 5
],
contextId: 'https%3A%2F%2Ftest.domain.com1000000000001563%3A89359961b094933bbad8477d368c335b99f84b7989359961b094933bbad8477d368c335b99f84b79_89359961b094933bbad8477d368c335b99f84b79',
path: '/',
user: 'e26c4380-4d3c-45b9-94d6-b933322dd38a',
targetLinkUri: 'http://localhost:3005',
context: {
id: '89359961b094933bbad8477d368c335b99f84b79',
label: 'English',
title: 'English',
type: [
'http://purl.imsglobal.org/vocab/lis/v2/course#CourseOffering',
[length]: 1
],
validation_context: null
},
resource: {
id: '89359961b094933bbad8477d368c335b99f84b79',
description: null,
title: null,
validation_context: null
},
launchPresentation: {
document_target: 'iframe',
height: null,
width: null,
return_url: 'https://test.domain.com/courses/31/modules',
locale: 'en',
validation_context: null
},
messageType: 'LtiResourceLinkRequest',
version: '1.3.0',
endpoint: {
scope: [
'https://purl.imsglobal.org/spec/lti-ags/scope/lineitem',
'https://purl.imsglobal.org/spec/lti-ags/scope/lineitem.readonly',
'https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly',
'https://purl.imsglobal.org/spec/lti-ags/scope/score',
[length]: 4
],
lineitems: 'https://test.domain.com/api/lti/courses/31/line_items',
validation_context: null
},
namesRoles: {
context_memberships_url: 'https://test.domain.com/api/lti/courses/31/names_and_roles',
service_versions: [ '2.0', [length]: 1 ],
validation_context: null
},
createdAt: '2020-12-30T03:06:52.081Z'
}
}
Expected behavior The expected response will be look like the provided response in the documentation in idToken
{
"iss": "http://localhost/moodle",
"clientId": "CLIENTID",
"deploymentId": "1",
"platformId": "60b1fce753c875193d71b611e895f03d"
"platformInfo": {
"product_family_code": "moodle",
"version": "2020042400",
"guid": "localhost",
"name": "moodle",
"description": "Local Moodle"
},
"user": "2", // this is what i need
"userInfo": {
"given_name": "Admin",
"family_name": "User",
"name": "Admin User",
"email": "local@moodle.com"
}
}
Ltijs version
Version 1.3 (maybe…) i got this information form package.json file NodeJS version
Version 12.19.0 - containerized in Docker with image node:12.19.0-alpine Platform used
Canvas
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Get ID Tokens
To get an ID token , you need to request them when authenticating users. Auth0 makes it easy for your app to authenticate...
Read more >How Encrypted ID Tokens Work
One way to achieve this is to encrypt ID tokens using JSON Web Encryption. Client applications will then receive an encrypted JWT and...
Read more >Using the ID token - Amazon Cognito
The ID token is a JSON web token (JWT) that contains claims about the identity of the authenticated user, such as name ,...
Read more >How to get user info from OpenId Id token?
Hi, I'm trying to use the Id Token, and i want to put some user information inside the Id Token. Unfortunately, i don't...
Read more >Authenticate with a backend using ID tokens
Get an ID token from the credentials object · Create an account or session · Securing your users' accounts with Cross Account Protection....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @Cvmcosta thanks for your help. I found the solution base on your idea.
Go to developer key -> Edit the key -> Additional Setting -> Custom Fields -> Then add the variables we want to get in platformContext of Ltijs token ( Get variables references via this link: https://github.com/instructure/canvas-lms/blob/master/doc/api/tools_variable_substitutions.md )![image](https://user-images.githubusercontent.com/41576363/103398794-c8aaf700-4b70-11eb-9cbb-c6a926292280.png)
After setup developer key , we can found the custom variables on
res.locals.token
Great! Happy to help!