I know that I can use the feathers JavaScript client lib to retrieve a security token. But I would like to use C# fronted to connect to a feathersjs backend. Is it possible to retrieve the security token using a simple rest call. I know that there is a /auth/local endpoint, but I have no idea how to use it directly.
Asked
Active
Viewed 2,263 times
2 Answers
5
This should work from console:
curl -X POST 'http://localhost:3030/auth/local' -H 'Content-Type: application/json' --data-binary '{ "email": "<EMAIL>", "password": "<PASSWORD>" }'
One thing that's not very clear in feathersJS documentation is that the configs in default.json/production.json files actually create auth services for each field in the "auth" object. For example with config containing
"auth": {
"idField": "id",
"token": {
"secret": {...},
"local": {},
"facebook": {
"clientID": "...",
"clientSecret": "...",
"profileFields": ["id", "name", "gender", "email", "picture.type(square).height(128).width(128)"],
"permissions": {
"scope": ["public_profile","email"]
}
},
"google": {
"clientID": "]...",
"clientSecret": "...",
"permissions": {
"scope": ["profile"]
}
}
}
You will get for free API endpoints
/auth/local
/auth/token
/auth/facebook/token
/auth/google/token
which you can call from any client (web, mobile, washing mashine)

Pz.
- 1,119
- 10
- 14
3
Ok, I have to post the Json object containing email, password and type local to the the /auth/local endpoint.

rogergl
- 3,501
- 2
- 30
- 49
-
Thank you for posting this! I had been looking all over their documentation and didn't see this url. Do you know if it is documented on their site? – Daniel Sikes Jun 02 '16 at 02:20
-
I tried this, but feathersjs returned me with HTML, instead of a JSON response. Did you get it to return you the auth token and/or "denied" response? – Ulysses Alves Jun 03 '16 at 14:34
-
You have to set the `Accept` header to `application/json`. Also, this is now documented at http://docs.feathersjs.com/authentication/readme.html#authentication-over-rest – Daff Jul 22 '16 at 06:04