我使用rails-api开发了一个API。
为了实现te API身份验证,我遵循了railscast:http://railscasts.com/episodes/352-securing-an-api。
在示例中,它使用authenticate_or_request_with_http_token
中的ActionController::HttpAuthentication::Token::ControllerMethods
来检查是否存在身份验证令牌。
我不知道怎么做是将此令牌从Angular发送到API。我必须把它放在标题中吗?什么标题?是否必须以某种方式编码?
答案 0 :(得分:3)
刚刚找到解决方案:
var authorizationHeader = 'Token token="' + token + '"'
AUTHORIZATION
标题中设置。