Closed darrenxyli closed 9 years ago
Hello @darrenxyli, can you show me how you crafted the API request? Ideally, in the form of a "curl" command that I can easily run against my own environment. Thanks!
Closed due to inactivity
Hi, I met a problem... with the command:
I want to generate a token with password.
curl -v -X POST -d "password:monkey" https://forum.singtown.cc/api/v2/users/73/tokens
and the response is 401.
Could you help me?
> POST /api/v2/users/73/tokens HTTP/1.1
> Host: forum.singtown.cc
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Length: 15
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 15 out of 15 bytes
< HTTP/1.1 401 Unauthorized
< Server: nginx/1.10.2
< Date: Tue, 02 Jan 2018 17:04:25 GMT
< Content-Type: application/json; charset=utf-8
< Content-Length: 115
< Connection: keep-alive
< X-Powered-By: NodeBB
< X-Frame-Options: SAMEORIGIN
< ETag: W/"73-qguwqDaxOp5T4EAjXF5td/L+gH4"
< set-cookie: express.sid=s%3AwtSl1-KdM1zFfrpdIH063FF33a2oLH_P.aSSqSd5iN%2Fnp8ENmDJoBd6td2y9pGG7tuQxbGP9j6Y4; Path=/; Expires=Tue, 16 Jan 2018 17:04:25 GMT; HttpOnly
< Vary: Accept-Encoding
<
* Connection #0 to host forum.singtown.cc left intact
{"code":"not-authorised","message":"A valid login session was not found. Please log in and try again.","params":{}}%
You need a token to call the API to create a token (seems silly, yes, I know).
The first token must be made from within the admin interface.
I am developing a mobile app, users can register and login. It seems that users can not get the token automatically?
Not at this time, no. To allow token generation using username and password necessitates creating a user control panel frontend for token management, and that is not done yet.
I tried to create token or post a topic for a user with api, no matter with master token or admin user token, but always give back error "A login session was not found. Please log in and try again.". Any idea, thanks.