Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid token. Please reinitiate login.

See original GitHub issue

Describe the bug Getting “Invalid token. Please reinitiate login.” HTTP 401 error in Moodle.

Expected behavior Show “It’s alive”

Provider logs LTI Provider is listening on port 3000! LTI provider config:

App Url: / Initiate login URL: /login Keyset Url: /keys Session Timeout Url: /sessionTimeout Invalid Token Url: /invalidToken provider:main Platform already registered. +37ms provider:main Platform already registered. +10ms provider:main Platform already registered. +7ms provider:main Receiving request at path: /login +4s provider:main Receiving a login request from: http://www.mymoodle.local +0ms provider:main Redirecting to platform authentication endpoint +2ms provider:main Generated state: c2735a621668668e +0ms provider:main Login request: { response_type: ‘id_token’, response_mode: ‘form_post’, id_token_signed_response_alg: ‘RS256’, scope: ‘openid’, client_id: ‘GISQB0HdF95ijvc’, redirect_uri: ‘’, login_hint: ‘2’, nonce: ‘Pm3Dp6GRYlXC4nb9CDM2vA==’, prompt: ‘none’, state: ‘c2735a621668668e’, lti_message_hint: ‘2’, lti_deployment_id: ‘1’ } +8ms provider:main Receiving request at path: / +75ms provider:main Path does not match reserved endpoints +0ms provider:main Cookies received: +0ms provider:main [Object: null prototype] {} +0ms provider:main No LTIK found +0ms provider:main Request body: [Object: null prototype] { error: ‘invalid_request’, state: ‘c2735a621668668e’ } +1ms provider:main Receiving request at path: /invalidToken +23ms


const path = require('path')

// Require Provider 
const LTI = require('ltijs').Provider

// Configure provider
const lti = new LTI('APPLTREEFRUIT', 
  { url: `mongodb://${process.env.DB_HOST}:${process.env.DB_PORT}/${process.env.DB_NAME}` , 
    connection: { 
          useUnifiedTopology: true , 
          useNewUrlParser: true, 
          authSource: 'admin',
          auth: { 
              password: process.env.DB_PASSWORD 
  {   appUrl: '/', 
      loginUrl: '/login', 
      logger: true , 

let setup = async () => {
  // Deploy and open connection to the database
  await lti.deploy()
  // Get the public key generated for that platform
  let plat = await lti.registerPlatform({ 
    url: 'http://www.mymoodle.local',
    name: 'Moodle Local',
    clientId: 'GISQB0HdF95ijvc',
    authenticationEndpoint: '',
    accesstokenEndpoint: '',
    authConfig: { method: 'JWK_SET', key: '' }
  // Set connection callback
  lti.onConnect((connection, request, response) => {
    // Call redirect function
    lti.redirect(response, '/main')
  }, { secure: false })

  // Set main endpoint route'/main', (req, res) => {
    // Id token
    res.send('It\'s alive!')


Ltijs version 4.1.0

NodeJS version v14.5.0

Platform used Moodle tool settings: Tool URL: Login URL: Redirect URL: Public key URL: (also tried copy/paste keys instead of URL)

Moodle tool config shows Platform ID: http://www.mymoodle.local Client ID: GISQB0HdF95ijvc Deployment ID: 1 Public keyset URL: http://www.mymoodle.local/mod/lti/certs.php Access token URL: http://www.mymoodle.local/mod/lti/token.php Authentication request URL: http://www.mymoodle.local/mod/lti/auth.php

Additional context Running bitnami/moodle in docker mapped to port 80 on localhost Running LTIJS in vscode remote container mapped to port 3000 on localhost www.mymoodle.local is localhost is

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

jeffmikocommented, Jul 8, 2020

I installed Moodle 3.7 on a clean virtual machine following the Ubuntu instructions and it is working now. I followed the steps in your Medium article. So it was definitely something to do with my docker setup or environment. I wonder if it had to do with DNS since I was running both Moodle and VSCode in docker containers. That’s why I was trying to use IP addresses initially. Thanks for your help.

Cvmcostacommented, Jul 8, 2020

I see, i’m glad it worked out!

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is an 'invalid token' when I try to reset my password?
Request a new token · Enter your email address and your new password; · Passwords must be at least eight characters and include...
Read more >
How to resolve "Your token has expired" message when ...
If you received the above message once, please try the steps below: Confirm you are selecting the most recently sent password reset email...
Read more >
What is the Invalid Token message - Bitfinex support
The error message "Invalid token. Please ensure you are logging in with the same browser within 15 minutes" usually occurs when...
Read more >
Fix Free Fire Access token invalid please relogin - YouTube
This tutorial is about how to fix free fire login problem access token invalid please relogin.This is also happening if you use facebook ......
Read more >
Facebook token is invalid or expired. Please reset token and ...
3 and higher. J'ai plusieurs sites de concernés. Merci de nous indiquer la marche à suivre. The page I need help with: [log...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found