我是LoopBack的新手。 我使用过它的默认服务器身份验证。
module.exports = function enableAuthentication(server) { // enable authentication server.enableAuth(); };在此之后我从登录api获取访问令牌。
然后我必须在所有服务调用url中传递它。
在loopback中是否有任何方式/设置允许我们在http标头中传递它而不是在http请求中传递url?
我正在使用angularjs。 使用此$http.defaults.headers.common['Authorization'] = 'access_token'.可以轻松为所有服务调用设置标头$http.defaults.headers.common['Authorization'] = 'access_token'.
但是如果我们必须在url param中传递它,那么我必须在每个服务调用中写入它。
任何人都可以建议一种方法在url param中为来自角度或环回设置的所有请求设置access_token以允许它在http标头中 。
回答重复:这个问题是相关的方法(如何)在角度侧的http调用中传递令牌。
I am new to LoopBack. I have used it's default server authentication.
module.exports = function enableAuthentication(server) { // enable authentication server.enableAuth(); };After this i am getting access token from login api.
Then i have to pass it in all service call url.
Is there any way/setting in loopback that allow us to pass it in http header instead of url in http request?
I am using angularjs. It is easy to set header for all service call using this $http.defaults.headers.common['Authorization'] = 'access_token'.
But if we have to pass it in url param then i have to write it in each service call.
Can anyone suggest a way to set access_token in url param for all requests from angular or loopback setting to allow it in http header.
Answer to duplicate : This question was related method(how to) pass token in header in http call from angular side.
最满意答案
Loopback允许您默认使用Authorization标头。 请参阅: https : //loopback.io/doc/en/lb3/Making-authenticated-requests.html#making-authenticated-requests-with-access-tokens
Loopback allows you to use an Authorization header by default. See: https://loopback.io/doc/en/lb3/Making-authenticated-requests.html#making-authenticated-requests-with-access-tokens
更多推荐
发布评论