Skip to content

Instantly share code, notes, and snippets.

@jmflannery
Created October 28, 2016 15:21
Show Gist options
  • Save jmflannery/5fc37eee4374315b9cbf05dab9ed5797 to your computer and use it in GitHub Desktop.
Save jmflannery/5fc37eee4374315b9cbf05dab9ed5797 to your computer and use it in GitHub Desktop.
authenticate_with_http_token example in a rails controller
def authenticate_token
@user = authenticate_with_http_token do |key, options|
token = Token.find_by key: key
token.user if token
end
head 401 unless @user
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment