Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Authenticate with simple rest call using feathersjs

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.

like image 403
rogergl Avatar asked Mar 19 '16 14:03

rogergl


2 Answers

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)

like image 184
Pz. Avatar answered Oct 21 '22 02:10

Pz.


Ok, I have to post the Json object containing email, password and type local to the the /auth/local endpoint.

like image 27
rogergl Avatar answered Oct 21 '22 02:10

rogergl