Comments (12)
Hi @alexschomb -- a bit of a delay, but I did test this just now, and it does work as intended. Here's what I did.
I created a new user token (0a8f70c3-75d9-40e1-b203-da7b4ad09ebe
), and made a curl without said token:
$ curl localhost:4567/api/un
read
{
"code": "not-authorised",
"message": "A valid login session was not found. Please log in and try again.",
"params": {}
}
With token:
$ curl localhost:4567/api/unread -H "Authorization: Bearer 0a8f70c3-75d9-40e1-b203-da7b4ad09ebe"
{
"showSelect": true,
"nextStart": 0,
"topics": [],
"topicCount": 0,
"categories": [
{
"cid": 5,
"name": "Test Group",
"icon": "hidden",
"bgColor": "rgba(0,0,0,0)",
"color": "rgba(0,0,0,0)",
"slug": "5/test-group",
"link": "",
"selected": false
},
{
"cid": 2,
"name": "General Discussion",
"icon": "fa-comments-o",
"bgColor": "#59b3d0",
"color": "#fff",
"slug": "2/general-discussion",
"link": "",
"selected": false
},
{
"cid": 4,
"name": "Comments & Feedback",
"icon": "fa-question",
"bgColor": "#e95c5a",
"color": "#fff",
"slug": "4/comments-feedback",
"link": "",
"selected": false
},
... etc...
So it does seem to work. Let me know if you still can't get it working.
from nodebb-plugin-write-api.
Interesting. I did exactly the same (but with different tokens) and always receive the not-authorized
code. I tried both master and user tokens, no joy. Running NodeBB v1.0.3 (latest stable).
$ curl http://127.0.0.1:33002/api/unread -H "Authentication: Bearer 49a11260-1be3-4db8-90c3-41302561d9ed"
{"code":"not-authorised","message":"A valid login session was not found. Please log in and try again.","params":{}}
from nodebb-plugin-write-api.
from nodebb-plugin-write-api.
Oops, you're right. That did solve the problem for the /api/unread
route. But I'm still receiving not-authorized
for the request of /api/users
:
$ curl http://127.0.0.1:33002/api/users -H "Authorization: Bearer 49a11260-1be3-4db8-90c3-41302561d9ed"
"not-authorized"
from nodebb-plugin-write-api.
I'm sorry, unfortunately I cannot reproduce this error:
$ curl localhost:4567/api/users -H "Authorization: Bearer 22e57cdc-3796-4330-8537-b4c1dff04eb1"
{
"loadmore_display": "hide",
"users": [
{
"username": "mango5",
"userslug": "mango5",
"joindate": 1466629097936,
"lastonline": 1466628804468,
"picture": "",
"reputation": 0,
"postcount": 0,
"banned": false,
"status": "offline",
"uid": 11,
"email:confirmed": false,
"icon:text": "M",
"icon:bgColor": "#827717",
"joindateISO": "2016-06-22T20:58:17.936Z",
"administrator": false,
"lastonlineISO": "2016-06-22T20:53:24.468Z"
},
...
]
}
from nodebb-plugin-write-api.
Does it help if I give you access to my forum? I can safely reproduce it for two separate NodeBB intances (v1.0.2 and v1.0.3)
from nodebb-plugin-write-api.
By the way, is it a master token or a regular user token you're using?
from nodebb-plugin-write-api.
I tried both. A master token would ask me to provide a uid for the /api/unread
call (as expected), but not for the /api/users
one. The latter always returns the exact string (no JSON) "not-authorized"
for any token (user or master).
# User token of an admin user
$ curl http://127.0.0.1:4567/api/unread -H "Authorization: Bearer fa14de0a-c384-4c80-b991-foobarcefd61"
{"showSelect":true,"nextStart":0,"topics":[],"categories":[{"cid":"1","name": ...
$ curl http://127.0.0.1:4567/api/users -H "Authorization: Bearer fa14de0a-c384-4c80-b991-foobarcefd61"
"not-authorized"
# Master token
$ curl http://127.0.0.1:4567/api/unread -H "Authorization: Bearer 5b54de45-5ccb-4b0d-be9b-foobard06b29"
{"code":"params-missing","message":"Required parameters were missing from this API call, please see the \"params\" property","params":["_uid"]}
$ curl http://127.0.0.1:4567/api/users -H "Authorization: Bearer 5b54de45-5ccb-4b0d-be9b-foobard06b29"
"not-authorized"
from nodebb-plugin-write-api.
Same issue here.
I have to request the read API /api/unread/ with _uid param once, and then request other API I want. If I don't do that, it will respond with 'not-authorized'
I can constantly reproduce this error:
- Remove all cookies.
- $ curl http://127.0.0.1:4567/api/users -H "Authorization: Bearer "
"not-authorized"
If (and only if) I do these:
- Remove all cookies.
- $ curl http://127.0.0.1:4567/api/unread -H "Authorization: Bearer "
{"showSelect": true,"nextStart": 0,"topics": [],"topicCount": 0, ...} - $ curl http://127.0.0.1:4567/api/users -H "Authorization: Bearer "
{"users": [...], "pagination": {...}, ...}
from nodebb-plugin-write-api.
Still unable to reproduce. Both user and master tokens work correctly, and I cannot get not-authorized
no matter what I try.
Perhaps it is the Node.js version you two are using? Use at least v4/5/6...
from nodebb-plugin-write-api.
Created token from Admin settings.
While accessing /users endpoint, I am getting not-authorised
error
from nodebb-plugin-write-api.
@mzahidriaz-tr please open a new issue. This one is from 2016.
Please provide a cURL command demonstrating the issue.
from nodebb-plugin-write-api.
Related Issues (20)
- Ban/Unban API v2 Endpoints not working
- Is there any api endpoint to send users an email to reset their password?
- Token generation api responses time out HOT 4
- 2FA HOT 11
- Timeout since upgrade with API v2 HOT 6
- This plugin doesn't appear in the list of the write plugins in my admin screen HOT 3
- Easier token revocation HOT 5
- error: Cannot set headers after they are sent to the client HOT 4
- Banned users cannot use write-api even after ban expires
- Create User from Node.js Failure. HOT 3
- Warn or prohibit creation of new user of same username HOT 2
- Follow logic is backwards HOT 1
- [Question] Create Topic as Current User HOT 2
- Access to admin pages with master token HOT 5
- Revoke Session via Write API HOT 1
- Upload functionality has been broken HOT 7
- How to delete user account + content? HOT 3
- Dependency Dashboard
- Please explain what does "Any other data passed in will be saved into the user hash" means HOT 1
- No bearer authentication for Read API HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodebb-plugin-write-api.