mobilefirst 8 中访问令牌的功能是什么
what is the function of access token in mobilefirst 8
起初,我希望在与 WL 资源通信时需要访问令牌。
预期流量:
1. WLAuthorizationManager.login(this.securityCheck ,{'username':username, 'password':password, rememberMe: true}).then(
2. WLAuthorizationManager.obtainAccessToken(this.securityCheck).then(
3. let resourceRequest = new WLResourceRequest('someURL', WLResourceRequest.GET)
resourceRequest.addHeader("Authorization", "Bearer " + accessToken);
4.
resourceRequest.send().then(
其中 1 = 登录,2 = 获取访问令牌,3 = 添加访问令牌到 header,4 = 访问资源
但是,我发现 没有 2、3,我仍然可以 访问资源。
我关心的是obtainAccessToken
是什么意思加上Authorization
header。
在login
之后是否有任何令牌自动绑定到WLResourceRequest
?
是否有其他不使用 WLAuthorizationManager.login
的登录方式?
如果可以,如何让服务器知道用户已登录,例如使用 WLAuthorizationManager.login
?
如果上述情况成立,自定义登录后,可以获得access token吗?
以下是关于这些方法及其工作原理的一些背景知识:
WLAuthorizatonManager.login(securityCheck, credentials) logs into a
specified security check. This method does not create an OAuth token.
有关 WLAuthorizatonManager.login(securityCheck, credentials) 的更多详细信息。
WLAuthorizationManager.obtainAccessToken(scope) returns an OAuth token
containing the specified scope.If the scope is mapped to a security check, it will trigger a corresponding challenge, which the client will have to handle to obtain the token. If obtainAccessToken(scope) is invoke after a successful login(securitycheck) call and if the scope is mapped to the same securitycheck, then you will not see a challenge. The OAuth token will be granted.
有关 obtainAccessToken() 的更多详细信息。
WLResourceRequest object is used to send a request to any protected or
unprotected resource using an absolute or relative URL.
WLResourceRequest object automatically handles the MobileFirst
OAuth-based security model protocol and invokes the required
challenges.
关于 WLResourceRequest 的详细信息。
回答您的问题:
是否有登录后自动绑定到WLResourceRequest的token?
如前所述,WLResourceRequest 自动协商来自 MFP 服务器的 OAuth 令牌,其中包含保护其正在访问的端点的范围。这可能包括多轮 OAuth 协商,并调用质询处理程序来处理来自服务器的质询。获得正确的令牌后,API 会自动将令牌添加到 'Authorization' header 中的请求中。
是否有其他不使用 WLAuthorizationManager.login 的登录方式?
而不是 WLAuthorizatonManager.login(securityCheck, credentials),如果通过 WLResourceRequest 访问受保护的资源,或者如果为映射到安全检查的范围调用 WLAuthorizationManager.obtainAccessToken(scope),则此将触发一个挑战响应周期,该周期将以用户身份和令牌结束。
如果可以,如何让服务器知道用户已登录,例如使用 WLAuthorizationManager.login(securityCheck, credentials)?
MFP 运行时会处理此问题 - 无论用户身份是通过 WLAuthorizatonManager.login() 设置的,还是 WLResourceRequest / WLAuthorizationManager.obtainAccessToken(scope) 触发通过安全检查的质询响应周期.
如果以上为真,自定义登录后是否可以获得access token?
不确定 'custom login' 是什么意思,但您始终可以使用 WLAuthorizationManager.obtainAccessToken(范围)或 WLResourceRequest 获取 OAuth 令牌。区别在于 obtainAccessToken() 将为您获取指定范围的令牌,而 WLResourceRequest 将通过自动获取覆盖所有必需范围的 OAuth 令牌来调用端点。
起初,我希望在与 WL 资源通信时需要访问令牌。
预期流量:
1. WLAuthorizationManager.login(this.securityCheck ,{'username':username, 'password':password, rememberMe: true}).then(
2. WLAuthorizationManager.obtainAccessToken(this.securityCheck).then(
3. let resourceRequest = new WLResourceRequest('someURL', WLResourceRequest.GET)
resourceRequest.addHeader("Authorization", "Bearer " + accessToken);
4.
resourceRequest.send().then(
其中 1 = 登录,2 = 获取访问令牌,3 = 添加访问令牌到 header,4 = 访问资源
但是,我发现 没有 2、3,我仍然可以 访问资源。
我关心的是obtainAccessToken
是什么意思加上Authorization
header。
在login
之后是否有任何令牌自动绑定到WLResourceRequest
?
是否有其他不使用 WLAuthorizationManager.login
的登录方式?
如果可以,如何让服务器知道用户已登录,例如使用 WLAuthorizationManager.login
?
如果上述情况成立,自定义登录后,可以获得access token吗?
以下是关于这些方法及其工作原理的一些背景知识:
WLAuthorizatonManager.login(securityCheck, credentials) logs into a specified security check. This method does not create an OAuth token.
有关 WLAuthorizatonManager.login(securityCheck, credentials) 的更多详细信息。
WLAuthorizationManager.obtainAccessToken(scope) returns an OAuth token containing the specified scope.If the scope is mapped to a security check, it will trigger a corresponding challenge, which the client will have to handle to obtain the token. If obtainAccessToken(scope) is invoke after a successful login(securitycheck) call and if the scope is mapped to the same securitycheck, then you will not see a challenge. The OAuth token will be granted.
有关 obtainAccessToken() 的更多详细信息。
WLResourceRequest object is used to send a request to any protected or unprotected resource using an absolute or relative URL. WLResourceRequest object automatically handles the MobileFirst OAuth-based security model protocol and invokes the required challenges.
关于 WLResourceRequest 的详细信息。
回答您的问题:
是否有登录后自动绑定到WLResourceRequest的token?
如前所述,WLResourceRequest 自动协商来自 MFP 服务器的 OAuth 令牌,其中包含保护其正在访问的端点的范围。这可能包括多轮 OAuth 协商,并调用质询处理程序来处理来自服务器的质询。获得正确的令牌后,API 会自动将令牌添加到 'Authorization' header 中的请求中。
是否有其他不使用 WLAuthorizationManager.login 的登录方式?
而不是 WLAuthorizatonManager.login(securityCheck, credentials),如果通过 WLResourceRequest 访问受保护的资源,或者如果为映射到安全检查的范围调用 WLAuthorizationManager.obtainAccessToken(scope),则此将触发一个挑战响应周期,该周期将以用户身份和令牌结束。
如果可以,如何让服务器知道用户已登录,例如使用 WLAuthorizationManager.login(securityCheck, credentials)?
MFP 运行时会处理此问题 - 无论用户身份是通过 WLAuthorizatonManager.login() 设置的,还是 WLResourceRequest / WLAuthorizationManager.obtainAccessToken(scope) 触发通过安全检查的质询响应周期.
如果以上为真,自定义登录后是否可以获得access token?
不确定 'custom login' 是什么意思,但您始终可以使用 WLAuthorizationManager.obtainAccessToken(范围)或 WLResourceRequest 获取 OAuth 令牌。区别在于 obtainAccessToken() 将为您获取指定范围的令牌,而 WLResourceRequest 将通过自动获取覆盖所有必需范围的 OAuth 令牌来调用端点。