0

I'm using LINE login module, I am able to access the oauth page but whenever I click Allow this app to login the response is Cannot/GET views/pages/callbackurl.ejs. This is the code that I run locally

  "use strict";

const app = require('express')();
const line_login = require("line-login");

const login = new line_login({
    channel_id: 15818,
    channel_secret: "6bfb55e907",
    callback_url: "http://localhost:5000/views/pages/callbackurl.ejs",
    scope: "openid profile",
    prompt: "consent",
    bot_prompt: "normal"
});

app.listen(process.env.PORT || 5000, () => {
    console.log(`server is listening to ${process.env.PORT || 5000}...`);
});

// Specify the path you want to start authorization.
app.use("/", login.auth());

// Specify the path you want to wait for the callback from LINE authorization endpoint.
app.use("http://localhost:5000/views/pages/callbackurl.ejs", login.callback((req, res, next, token_response) => {
    // Success callback
    res.json(token_response);
},(req, res, next, error) => {
    // Failure callback
    res.status(400).json(error);
}));
2
  • Please remove channel_id and channel_secret from this public question, if are valid. Commented Jan 26, 2018 at 15:59
  • nope they're not valid. I've edited it already, its not the real id and channel secret Commented Jan 26, 2018 at 16:00

1 Answer 1

1

You are facing the issue, because your callback url is /views/pages/callbackurl.ejs. Whenever authentication is successful, Line redirects back to callback_url mentioned in LineOptions, but in your case, you have not implemented /views/pages/callbackurl.ejs. It is /callbackurl.

So, you can change callback_url to http://localhost:5000/callbackurl to get valid redirection after successful oauth.

const app = require('express')();
const line_login = require("line-login");

const login = new line_login({
   channel_id: 15818,
   channel_secret: "6bfb55e907",
   callback_url: "/callbackurl",  // Update this url on Line developer portal
   scope: "openid profile",
   prompt: "consent",
   bot_prompt: "normal"
});

app.listen(process.env.PORT || 5000, () => {
   console.log(`server is listening to ${process.env.PORT || 5000}...`);
});

// Specify the path you want to start authorization.
app.use("/", login.auth());

// Specify the path you want to wait for the callback from LINE authorization endpoint.
app.use("/callbackurl", login.callback((req, res, next, token_response) => {
   // Success callback
   res.json(token_response);
},(req, res, next, error) => {
   // Failure callback
   res.status(400).json(error);
}));
Sign up to request clarification or add additional context in comments.

5 Comments

thank you for the response, im still getting the same error. should I use app.get()?
app.use should be fine, but you can try app.get. You must update callback_url in code as well as on Line developer portal.
can you update the latest code in question and error you are getting?
As we can see you have wrongly mentioned callback_url and route.
hi Mukesh. thank you. redirection works, however I cannot output res.json, in the callback url , the app is deployed in Heroku for live testing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.