authenticate_or_request_with_http_token
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0 (0)
- 3.0.9 (0)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (38)
- 7.1.3.4 (0)
- What's this?
authenticate_or_request_with_http_token(realm = "Application", message = nil, &login_procedure)
public
Authenticate using an HTTP Bearer token, or otherwise render an HTTP header requesting the client to send a Bearer token. For the authentication to be considered successful, login_procedure should return a non-nil value. Typically, the authenticated user is returned.
See ActionController::HttpAuthentication::Token for example usage.
An Example for using it.
Call it in a before filter in your Base or Application Controller.
before_filter :authenticate_through_api_client
def authenticate_through_api_client
# this block should return true or false authenticate_or_request_with_http_token |token,other_options| Apiclient.find_by_client_key(token).present? end
end
# Sample request type: it expects a token in headers as
Authorization:Token token=“your_token_goes_here”
Authorization is the key and Token token=“” is value
Article
Here is artice about this method http://blog.envylabs.com/post/75521798481/token-based-authentication-in-rails