i own my nodebb, i want to use a third-part id to login to my nodebb.
what must i do?
is there api docs ?
thanks.
i own my nodebb, i want to use a third-part id to login to my nodebb.
what must i do?
is there api docs ?
thanks.
i got it.
it's cause webview 's layout_width (in xml) and height is not set to match_parent by default.
i do the same thing with a empty project. all is right.
before is with basic project.
it 's surprised. i found that the menu could show more . but still has some below cannot show.
yes. i tried opera or firefox, it can show menu completely.
it need to set which option of webview?
main menu cannot move down anymore
i use a webview to open nodebb.org
but why the main menu doesnt show all menu items?
thanks
the code with python is success
#coding=utf-8
import requests
client = requests.session()
csrf = client.get(url='https://172.16.220.133/api/config', verify=False).json()["csrf_token"]
print csrf
r = client.post(url='https://172.16.220.133/login', verify=False, data={'username':'creatxr', 'password':'creatxr'}, headers={'x-csrf-token': csrf})
print r.content
the code with promised request is success
async function authBB(name,pass) {
let jar = requestPromise.jar();
let res = await requestPromise({
url: 'https://172.16.220.133/api/config',
json: true,
jar: jar,
rejectUnauthorized: false,
requestCert: true,
agent: false,
});
console.log(res.csrf_token);
res = await requestPromise.post('https://172.16.220.133/login', {
form: {
username: name,
password: pass,
},
json: true,
jar: jar,
rejectUnauthorized: false,
requestCert: true,
agent: false,
headers: {
'x-csrf-token': res.csrf_token,
},
// resolveWithFullResponse: true
});
console.log(res.header.user);
console.log(res);
console.log(res.statusCode);
}
now the code below with axios is success.
const axiosCookieJarSupport = require('axios-cookiejar-support').default;
const tough = require('tough-cookie');
axiosCookieJarSupport(axios);
async function authNodeBB(name,pass) {
let cookieJar = new tough.CookieJar();
let instance = await axios.create({
jar:cookieJar,
withCredentials: true,
httpsAgent: new https.Agent({ rejectUnauthorized: false, requestCert: true, keepAlive: true})
});
let res = await instance.get('https://172.16.220.133/api/config');
console.log(res.data.csrf_token);
instance.defaults.headers['x-csrf-token'] = res.data.csrf_token;
res = await instance.post('https://172.16.220.133/login',{username:name,password:pass});
console.log(res.statusCode);
console.log(res);
}
i did
systemctl stop nodebb
cd nodebb dir
run ./nodebb upgrade
systemctl start nodebb
visit nodebb by browser
in admin panel, it still shows v1.11.1
it seems that './nodebb upgrade' not works.
after run this command and start nodebb, it still shows
'running nodebb v1.11.1 upgrade to v1.12.0'
it seems that 'jar' option is required. without it, even with csrf token, the reponse is '403 err'
yes, i know. i've tried. console print before data return.
i just want to know how the auth works, then to find the way to do what i want.
thanks
thanks.
if success, code is 200 ? i think i get it.
if not , code is 403 ? or maybe has others.
async function loginNodeBB(name,pass) {
let jar = request.jar();
let res = await request({
url: 'https://172.16.220.133/api/config',
json: true,
jar: jar,
rejectUnauthorized: false,
requestCert: true,
agent: false,
}, function(err,res,body) {
if(err) {
console.log(err);
}
console.log('11111111111111');
request.post('https://172.16.220.133/login', {
form: {
username: name,
password: pass,
},
json: true,
jar: jar,
rejectUnauthorized: false,
requestCert: true,
agent: false,
headers: {
'x-csrf-token': body.csrf_token,
},
}, function (err, res, body) {
//callback(err, response, body, jar);
console.log(err);
// console.log(res);
// console.log(jar);
});
}
);
}
now i change like this,
even username or password is wrong,
the err always is 'null'
how can i know authentication is passed?
if i do like this
async function loginNodeBB(name,pass) {
let jar = request.jar();
let res = await request.post('https://172.16.220.133/login',{
form: {
username: name,
password: pass
},
json: true,
jar: jar,
rejectUnauthorized: false,
requestCert: true,
agent: false,
headers: {
}
},
function (err, response, body) {
console.log(body);
console.log('1111111111111');
}
);
console.log(res.body);
}
output is:
username=creatxr&password=creatxr
Forbidden
1111111111111
i write code like it's in the test .js below:
async function loginNodeBB(name,pass) {
let jar = request.jar();
let res = await request.post('https://localhost/login',{
form: {
username: name,
password: pass
},
json: true,
jar: jar,
rejectUnauthorized: false,
requestCert: true,
agent: false,
headers: {
}
});
console.log(res.body);
}
loginNodeBB('creatxr','creatxr');
console message is:
username=creatxr&password=creatxr
it doesn't get the info if the user is authenticated or not !