lynndylanhurley / devise_token_auth

Token based authentication for Rails JSON APIs. Designed to work with jToker and ng-token-auth.
Do What The F*ck You Want To Public License
3.54k stars 1.13k forks source link

React on Rails with Devise Token Auth #1531

Open danilomartinelli opened 2 years ago

danilomartinelli commented 2 years ago

Hey guys, I am tring to use the framework React on Rails with devise otken auth lib, I need to pass the authorization headers as cookies to use server side :authenticate_api_user! and current_api_user, I enabled the cookie configuration and set the access-token as cookie, but I got a error unexpected token

mdodell commented 2 years ago

I'm also having this same issue!

theblang commented 2 years ago

Hey @danilomartinelli ! Quick question, did you set any config.cookie_attributes? Also, could you add a screenshot of the Cookies tab in devtools for the /auth/sign_in request?

danilomartinelli commented 2 years ago

Hey @danilomartinelli ! Quick question, did you set any config.cookie_attributes? Also, could you add a screenshot of the Cookies tab in devtools for the /auth/sign_in request?

@theblang I didn't set cookie_attributes, What Do I need to set?

theblang commented 2 years ago

@danilomartinelli You can set any of the standard Rails attributes. If you're not setting expires, then I think Rails defaults to end of session.

dberardo-com commented 1 year ago

hi there, i hope this question is related:

so basically user can authenticate both via token "auth/" or via regular "users/sign_in" url and thanks to the shared cookie it will be authorized on both endpoints without need of relogin.

same would go for logout.