在标头中传递访问令牌而不是url loopback(Pass access token in header instead of url loopback)

编程入门 行业动态 更新时间:2024-10-26 16:30:41
在标头中传递访问令牌而不是url loopback(Pass access token in header instead of url loopback)

我是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

更多推荐

本文发布于:2023-04-29 06:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1335267.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:令牌   而不是   url   标头中   loopback

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!