5

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.

2 Answers 2

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)

Sign up to request clarification or add additional context in comments.

Comments

3

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

3 Comments

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?
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?
You have to set the Accept header to application/json. Also, this is now documented at docs.feathersjs.com/authentication/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.