Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@uauth/node - login issue - Invalid request, verification methods not defined #66

Open
abdulqawibhoira opened this issue Sep 21, 2022 · 0 comments

Comments

@abdulqawibhoira
Copy link

abdulqawibhoira commented Sep 21, 2022

When I try to login, I get the following error on a redirect.

Error: invalid_request: Invalid request, verification methods not defined
at callback (/project/node_modules/@uauth/node/build/index.js:312:17)

I have used the exact same code from node server docs. Sharing the code for reference.

What am i missing here ?

const express = require('express');
const session = require('express-session');
require('express-async-errors')

require('whatwg-fetch');
global.XMLHttpRequest = require('xhr2')
global.XMLHttpRequestUpload = global.XMLHttpRequest.XMLHttpRequestUpload;

const { Client } = require('@uauth/node');
const { Resolution } = require('@unstoppabledomains/resolution');

const app = express();
const port = 3333;

app.use(session({ secret: 'keyboard cat' }));

app.use(express.urlencoded({ extended: true }));

const client = new Client({
clientID: "",
clientSecret: "",
clientAuthMethod: "client_secret_post",
redirectUri: "http://localhost:3333/callback",
scope: "openid wallet",
resolution: new Resolution(),
})

const { login, callback, middleware } = client.createExpressSessionLogin();

app.post('/login', (req, res, next) => {
return login(req, res, next, {
username: req.body.domain,
})
})

app.post('/callback', async (req, res, next) => {
console.log('Calling back!')

await callback(req, res, next)

return res.redirect('/profile')
})

const onlyAuthorized = middleware()

app.get('/profile', onlyAuthorized, (req, res) => {
res.json(res.locals.uauth)
})

app.get('/', (_, res) => {
const indexPage =
<!DOCTYPE html><html><body> <form action="/login" method="POST"> <input name="domain" id="domain" /> <button type="submit">Login</button> </form> </body></html>

return res.send(indexPage)
})

app.listen(port, () => {
console.log(Example app listening at http://localhost:${port})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant