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

Updating localStorage Auth Token #20

Open
mhaagens opened this issue Jan 13, 2016 · 6 comments
Open

Updating localStorage Auth Token #20

mhaagens opened this issue Jan 13, 2016 · 6 comments

Comments

@mhaagens
Copy link

I can't seem to get the Auth Token saved in localStorage to refresh.
From what I understand each request to the API should send back a new token,
but the token in jToker doesn't update. Could someone point me in the right direction?

@zarembas
Copy link

Hi, have you managed to get the token saved somehow? Neither cookies nor localStorage works for me.

Update 1: I found out why it's not working for me, because it doesn't read the custom header values. Unfortunately, I have yet to find a solution.

Update 2: Adding the expose option to a resource in rack-cors solves this issue.

config.middleware.insert_before 0, 'Rack::Cors' do
  allow do
    origins '*'
    resource '*', headers: :any, expose: ['access-token', 'token-type', 'client', 'expiry', 'uid'], methods: [:get, :post, :options, :patch]
  end
end

@timsatterfield
Copy link

Look at the casing of the response headers... this has tripped me up in all sorts of scenarios that depend on auth headers, not just using this lib. I dont know why, but some appservers upcase each word =(

@stubblsc
Copy link

@vassyz was having same problem and what you said fixed it. thanks!

@up_the_irons
Copy link

I was having the same issue, in 2023! Adding 'access-token', 'token-type', 'client', 'expiry', 'uid' to my expose headers in config/initializers/cors.rb saved the day 🙏🏻

@zarembas
Copy link

Didn't think anyone was still using this in 2023. Can't even remember what I was doing with it back then.

@up_the_irons
Copy link

It's hard to find something that does token auth with a Rails 7 backend these days. All the new frameworks want to sell you on their serverless JS-only toys. But I'm open to suggestions 😃 I've only been at this new project for a few days...

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

5 participants