Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

400
Visualizações
The best way to store a JWT in ruby

I am currently integrating our system, with an external api. I am using httparty to facilitate the integration.

When I do auth with the external-api we are provided with a JWT, is there a best practice for storing this JWT for future requests in ruby?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Thew JWT Ruby Gem should be your first choice for Ruby implementation. There are a few other Gems. For more information on JWT in general you may refer to the gem's documentation or perhaps here.

Regarding best practice for storing the JWT, it really depends on your use case, but for yours, it sounds like you'd want to use a temporary cache type store such as Redis if you're JWT has a typical expiration time. The ideas is that after authentication, you write the token to a temporary store, which might look like this if you were using Redis.

require 'redis'


my_jwt_token = call_some_api_to_get_token

redis = Redis.new (
    :host => 'hostname',
    :port => port,
    :password => 'password')

token_expires_in_seconds = 60 * 60 # set expire 1 hour
redis.set('my_jwt_token', my_jwt_token, ex: token_expires_in_seconds)

my_api_client.call('some_endpoint', jwt_token: redis.get('my_jwt_token"))

In my example I'm assuming you have a client object with a call method which takes an endpoint and the options hash. But this should give you a basic idea of an approach here.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda