GithubHelp home page GithubHelp logo

Comments (12)

waiting-for-dev avatar waiting-for-dev commented on August 17, 2024

Hi @bin4ryio .

Usually, if you just want the jwt token to be dispatched in a regular sign_in and to be revoked in a regular sign_out, there is no need to manually configure jwt.dispatch_requests neither jwt.revocation_requests, as they are detected automatically.

Also, note that you have a typo. It is request_formats and not requests_formats (the extra s).

So, I think that with following configuration it should work:

config.jwt do |jwt|
    # jwt.secret = ENV['DEVISE_JWT_SECRET_KEY']
    jwt.secret = "d8f531be58ad478cc79d072d6c4ea777a0c6ca5fbd9a2194b6fbfcea5f4f122017092a593f31576a0c27d9478f1bd74d336945481d22c7f9af36fd2fa6061c3d"
    jwt.request_formats = { user: [:json] }
  end

from devise-jwt.

waiting-for-dev avatar waiting-for-dev commented on August 17, 2024

Going to close it now. Feel free to come back with more questions.

from devise-jwt.

darr1s avatar darr1s commented on August 17, 2024

Hello, thanks the the prompt reply @waiting-for-dev. However, I have checked my devise.rb and the typo was not there. It was written jwt.request_formats = { user: [:json] } and the problem continue to persist.

from devise-jwt.

waiting-for-dev avatar waiting-for-dev commented on August 17, 2024

Can you copy/paste here which configuration do you have now?

from devise-jwt.

darr1s avatar darr1s commented on August 17, 2024

I still could not understand why it return unexpected ''. May I ask if your environment is Rails API or Rails default?

Here's the gist:
https://gist.github.com/bin4ryio/7a4c9bf1b8d5ec1dbbd195dd06ad26e1

Thanks.

from devise-jwt.

darr1s avatar darr1s commented on August 17, 2024

No clear advice given. But I'm able to get Bearer by adding :head on CORS config and it will not work if devise_for has a :path api/v1/users option. Thank you anyways.

from devise-jwt.

mits87 avatar mits87 commented on August 17, 2024

Someone has full example of use this gem?

from devise-jwt.

waiting-for-dev avatar waiting-for-dev commented on August 17, 2024

Hey @bin4ryio . Sorry, I missed your last message. This gem should work with both Rails API or default.

Happy to see now it works for you. About the path option, it should also work with it. It would be useful if you could prepare an example application that reproduces the bug.

Cheers

from devise-jwt.

waiting-for-dev avatar waiting-for-dev commented on August 17, 2024

@mits87 , in spec/fixtures/rails_app/ you have an example application used for testing purposes. You only need to configure CORS on top of that if you are using cross domain requests. See rack-cors for that.

from devise-jwt.

darr1s avatar darr1s commented on August 17, 2024

Realize its my mistake for not reading correctly. Everything is working for intended now. Thanks for the great gem and prompt support @waiting-for-dev

I also use this to encode user's email into payload, maybe adding it to front-page to help beginner out.

   def jwt_payload
     { 'email' => email }
   end```

from devise-jwt.

waiting-for-dev avatar waiting-for-dev commented on August 17, 2024

Happy to hear that @bin4ryio :)

The information about the way to add custom claims to the payload is already in the README. Don't forget to call super if you are using JTIMatcher revocation strategy, though.

from devise-jwt.

 avatar commented on August 17, 2024

@bin4ryio could u please clarify how did u return authorization header

from devise-jwt.

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.