在这种情况下,用户需要批准两个不同的提示:一个用于身份验证,另一个用于授予 Cookie 访问权限,因为 SAA 会触发权限提示。FedCM 通过充当信任信号来简化 Storage Access API 流程。用户使用 FedCM 登录后,系统会自动授予 IdP 发起的存储空间访问权限请求,从而无需额外的 SAA 提示。
// In top-level rp.example:
// Ensure FedCM permission has been granted.
const cred = await navigator.credentials.get({
identity: {
providers: [{
configURL: 'https://idp.example/fedcm.json',
clientId: '123',
}],
}
});
// In an embedded IdP iframe:
// Returns `true` if the user already has access to cookies, and `false` if
// the user doesn't have access yet and needs to request it.
const hasAccess = await document.hasStorageAccess()
if(!hasAccess){
// No user gesture is needed to approve storage access, and the call will be auto-granted.
document.requestStorageAccess().then(e=>{
//access cookies
})
} else{
//the iframe already has access to third-party cookies
}
Origin 试用参与者提供了积极的反馈,强调了与通用 Storage Access API 提示相比,特定于上下文的 FedCM 提示可提供更出色的用户体验。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2024-11-15。"],[[["Chrome now uses FedCM as a trust signal for the Storage Access API, streamlining cross-origin iframe storage access when users are logged in with FedCM."],["This integration eliminates the need for separate Storage Access API prompts, simplifying the user experience and reducing prompt fatigue."],["Websites using both FedCM and the Storage Access API benefit from this feature, as users only need to authenticate once with FedCM for both login and storage access."],["Developers can learn more about implementation and feedback channels through provided documentation and issue tracking links."],["Positive feedback from origin trial participants suggests that FedCM-based storage access improves user experience compared to generic prompts."]]],[]]