Skip to content

Getting members issue  #249

@aymaneallaoui

Description

@aymaneallaoui

Describe the bug
i tried to setup the server code implementation code example but the getting members always fails
here is the res.locals.token output:

{
  iss: 'http://local.moodle.example.me',
  user: '2',
  userInfo: {
    given_name: 'Admin',
    family_name: 'User',
    name: 'Admin User',
    email: 'user@example.com'
  },
  platformInfo: {
    product_family_code: 'moodle',
    version: '2023100908',
    guid: '39f301cbe9b54798cb4e5774bfd621c8',
    name: 'New Site',
    description: 'New Site'
  },
  clientId: 'Jb8JFH57UH0sZMG',
  platformId: 'd8ead2686f7d1c4204c8dc27d9824d86',
  deploymentId: '1',
  createdAt: '2024-12-24T23:07:30.405Z',
  platformContext: {
    contextId: 'http%3A%2F%2Flocal.moodle.example.meJb8JFH57UH0sZMG179_1_a73e6612b589fd58fa633db4026f99c70a292a13a93fc32598b4ffe064d642b6',
    user: '2',
    roles: [
      'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Administrator',
      'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
      'http://purl.imsglobal.org/vocab/lis/v2/system/person#Administrator'
    ],
    path: '/',
    targetLinkUri: 'https://29e7-160-164-153-90.ngrok-free.app',
    context: { id: '79', label: 'gggg', title: 'test LTI', type: [Array] },
    resource: { title: 'integration', description: '', id: '1' },
    custom: {
      context_memberships_url: 'http://local.moodle.example.me/mod/lti/services.php/CourseSection/79/bindings/1/memberships'
    },
    launchPresentation: {
      locale: 'en',
      document_target: 'iframe',
      return_url: 'http://local.moodle.example.me/mod/lti/return.php?course=79&launch_container=3&instanceid=1&sesskey=oNepeJBWZB'
    },
    messageType: 'LtiResourceLinkRequest',
    version: '1.3.0',
    lis: { person_sourcedid: '', course_section_sourcedid: '' },
    endpoint: {
      scope: [Array],
      lineitems: 'http://local.moodle.example.me/mod/lti/services.php/79/lineitems?type_id=1'
    },
    namesRoles: {
      context_memberships_url: 'http://local.moodle.example.me/mod/lti/services.php/CourseSection/79/bindings/1/memberships',
      service_versions: [Array]
    },
    createdAt: '2024-12-24T23:07:30.419Z'
  }
}

here is the code snippet

router.get("/members", async (req, res) => {
  try {
    console.log("Token", res.locals.token);
    const result = await lti.NamesAndRoles.getMembers(res.locals.token);
    console.log("Result", result);
    if (result) return res.send(result.members);
    return res.sendStatus(500);
  } catch (err) {
    console.log(err.message);
    return res.status(500).send(err.message);
  }
});

Expected behavior
A clear and concise description of what you expected to happen.

Provider logs
Copy of the relevant provider logs.

  1. Run code with debug flag: DEBUG=provider:* npm start.
  2. Copy logs relevant to the issue.

Screenshots
image

Ltijs version

  • Version [e.g. 4.0.7]

NodeJS version

  • Version [e.g. 12]

Platform used

  • Moodle

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions