Coder Social home page Coder Social logo

Token invalid about silverstripe-restfulapi HOT 9 CLOSED

colymba avatar colymba commented on July 30, 2024
Token invalid

from silverstripe-restfulapi.

Comments (9)

colymba avatar colymba commented on July 30, 2024

Do you have a sample request payload and headers we could look at? How are you passing the token? It should be in a X-Silverstripe-Apitoken header or fallback to a requestVar.

from silverstripe-restfulapi.

luukgruijs avatar luukgruijs commented on July 30, 2024

Thanks for your answer,

I was just testing everything by typing the url in the browser and see the return on my localhost. If i understand you correctly we need to store te tokens in the header where we do the get or post? All the REST stuff is kind off new for me so i have to figure that out.

from silverstripe-restfulapi.

colymba avatar colymba commented on July 30, 2024

if you try something like api/TherapyGroup/1?X-Silverstripe-Apitoken=XX you should actually get an output in your browser (replacing XX with an actually token). The TokenAuthenticator fallsback onto a request var to get the token if it is not in the header.

One easy way to get a token is via the Auth methods: api/auth/login?email=***&pwd=***

Otherwise, Postman for Chrome is pretty good if you want to test stuff: https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en

from silverstripe-restfulapi.

luukgruijs avatar luukgruijs commented on July 30, 2024

Thanks again,

i tested it in Postman and when i do a get with headers it works but when i do it with URL parameters it doesn't work.

At least i could go on now. Thanks!

from silverstripe-restfulapi.

colymba avatar colymba commented on July 30, 2024

Cool, good to hear.

from silverstripe-restfulapi.

jnoliver2 avatar jnoliver2 commented on July 30, 2024

Im using the latest stable version and this does not work. It is failing when it tries to read the generated token in the database on function validateAPIToken. The ApiToken field is not in the Members fields. I had to decorate the members class with ApiToken field and ApiTokenExpire for this to work. Was I missing something?

from silverstripe-restfulapi.

luukgruijs avatar luukgruijs commented on July 30, 2024

I think you forget the right things in config.yml. https://github.com/colymba/silverstripe-restfulapi/blob/master/doc/TokenAuthenticator.md#token-authentication-data-extension-restfulapi_tokenauthextension

from silverstripe-restfulapi.

jnoliver2 avatar jnoliver2 commented on July 30, 2024

Aha.. I didn't see that. Please Include it on the example config you gave on README. Thought those were all the configs needed.

from silverstripe-restfulapi.

colymba avatar colymba commented on July 30, 2024

as mentioned by @luukgruijs did you add the RESTfulAPI_TokenAuthExtension and updated tokenOwnerClass accordingly?

from silverstripe-restfulapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.