有这样的设置:
localhost:3000
localhost:9990,localhost:8080,用户可以通过向以下用户发送用户名+密码在SPA上“登录”/获取令牌:
http://localhost:9990/auth/realms/w/protocol/openid-connect/token然后,我在auth服务器上调用另一个url,该url应该设置SSO/ HttpOnly -me(它应该设置一些cookie)所需的keycloak所需的cookie:
.then(t => keycloakInstance.init({
token: t.access_token,
refreshToken: t.refresh_token,
checkLoginIframe: false, // required to init with token
})
.then((authenticated) => {
console.log('auth', authenticated); // <-- it is true
if (authenticated) {
return fetch('http://localhost:9990/auth/realms/w/custom-sso-provider/sso', { headers: {
Authorization: `Bearer ${keycloakInstance.token}` } })
// else请求本身似乎很好,Set-Cookie就像我所期望的那样发生;这是响应头:

我现在希望它们出现在devtools > Application > cookies中,但不幸的是,没有出现cookie。为什么?我能做些什么?
发布于 2020-10-20 07:54:14
我错过了credentials: 'include'的fetch电话:
return fetch('http://localhost:9990/auth/realms/w/custom-sso-provider/sso', { headers: { Authorization: `Bearer ${keycloakInstance.token}` }, credentials: 'include' })https://stackoverflow.com/questions/64440508
复制相似问题