Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JWT to memory #436

Closed
apaciuk opened this issue Jul 27, 2021 · 2 comments
Closed

JWT to memory #436

apaciuk opened this issue Jul 27, 2021 · 2 comments

Comments

@apaciuk
Copy link

apaciuk commented Jul 27, 2021

Hi not an issue as such but has anyone used this gem and saved token in memory rather than local storage/cookies in rails? Is there a way of doing that?

Thanks

@anakinj
Copy link
Member

anakinj commented Aug 18, 2021

Think this gem is not really related to storing tokens. But one way to store tokens in memory would be to have a class variable as storage. This approach is probably only suitable if the tokens are specific for the application and is not that dynamic, like depending on the user of the application.

module MyMemoryTokenCache
  def self.cached_token
    @cached_token = nil if @cached_token.expired?

    @cached_token ||= fetch_token
  end

  def self.fetch_token
    # Generate/fetch the token from 3rd party
  end
end

@apaciuk
Copy link
Author

apaciuk commented Aug 19, 2021 via email

@anakinj anakinj closed this as completed Aug 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants