SAP Spartacus 会使用 Session timeout 吗?
问题:Where to configure session timeout in Spartacus
答案
我假设您使用 Hybris OAuth 服务器的默认身份验证流程(密码流程)。 在这种情况下,会话长度是通过后台的 OAuth 客户端设置来控制的。
但是,要知道会话何时到期,您可以检查令牌有效负载 (AuthStorageService.getToken)。属性之一是到期时间,可用于了解会话何时实际结束。
Marcin is correct. Spartacus is 100% API driven, interacting with Commerce backend by sending request to configured endpoints. These endpoints require an access token to be sent with the request, and this access token needs to be retrieved by following the Client Credentials Flow that is defined by the OAuth specification.
As long as you log in successfully, you can find access token issued by Commerce backend in Chrome dev tools, application tab -> Local storage as highlighted below:
the field expires_at stores the value of exact date and time when token will be expired.
you can use the code below in console to convert it to human readable string:
new Date(1627660784476).toGMTString();
You can control the token time-to-live value via configuration in backoffice by property: oauth2.accessTokenValiditySeconds
See document for detail:
https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/2105/en-US/3d3ea6a4d5fa486aa324ce278fa2afc3.html?q=oauth2.accessTokenValiditySeconds
if you need to code in Spartacus to know when the token will be expired, inject AuthStorageService in your app.module.ts, and then access expires_at property of result returned by getToken method.
export class AppModule {
constructor(private authService: AuthStorageService){
const token: Observable<AuthToken> = this.authService.getToken();
token.subscribe((token) => console.log('expire at:' , token.expires_at));
}
}
更多Jerry的原创文章,尽在:“汪子熙”:
相关文章
- SAP UI5 sap.ui.base.ManagedObject 的构造函数参数讲解
- SAP UI5 sap.ui.export.Spreadsheet API 介绍
- SAP UI5 Table 控件数据进行 Excel 导出时如何进行格式控制
- SAP UI5 sap.ui.Device.media.initRangeSet 方法的单步调试
- SAP MM 自动化处理之公司间退货STO交货单自动创建
- SAP UI5 Smart Value Help 总结
- PHP session_start():开启Session
- SAP选择屏幕详解编程语言
- SAP 录屏BDC使用—实例详解编程语言
- SAP 获取用户IP、操作记录详解编程语言
- 系统Oracle公司收购SAP系统开启新的商业时代(Oracle公司sap)
- Oracle从SAP抽取数据的简单方法(oracle从sap抽数)
- 数据库解决方案如何使用SAP创建Redis数据库(sap怎么创建redis)
- 对比Oracle和SAP价格比较哪个是更值得投入的选择(oracle与sap价格)
- Oracle SAP系统深入探索管理系统之魅力(oracle sap系统)
- Oracle和SAP教程一步一步学习(oracle sap教程)