if ('IdentityCredential' in window) {
// AJAX call to login
navigator.login.setStatus('logged-in');
// TODO handle user canceling
const credential = await navigator.credentials.get({
identity: {
// Specify the IdP (or multiple IdPs, supported from Chrome 136) this Relying Party supports
providers: [
{
configURL: 'https://accounts.google.com/gsi/fedcm.json',
clientId: '',
nonce: crypto.randomUUID()
}
]
}
});
console.log(credential);
}
< /code>
и идентификатор клиента имеет 2 URL -адреса в авторизованных доменах JS. Один из них - общедоступный HTTPS -сервер, который я запускаю. Когда я проверяю это там, это работает нормально, и я получаю учетные данные. Но когда я запускаю это на Localhost: 3000, и у меня есть http: // localhost: 3000 в авторизованном домене JS, я все еще получаю
The fetch of the id assertion endpoint resulted in a network error: ERR_FAILED
localhost/:1 Server did not send the correct CORS headers.
main.js:26 Uncaught (in promise) IdentityCredential
Error: Error retrieving a token.
Я работаю с FedCM API для аутентификации. Я использую это < /p> [code]if ('IdentityCredential' in window) { // AJAX call to login navigator.login.setStatus('logged-in');
// TODO handle user canceling const credential = await navigator.credentials.get({ identity: { // Specify the IdP (or multiple IdPs, supported from Chrome 136) this Relying Party supports providers: [ { configURL: 'https://accounts.google.com/gsi/fedcm.json', clientId: '', nonce: crypto.randomUUID() } ] } }); console.log(credential); } < /code> и идентификатор клиента имеет 2 URL -адреса в авторизованных доменах JS. Один из них - общедоступный HTTPS -сервер, который я запускаю. Когда я проверяю это там, это работает нормально, и я получаю учетные данные. Но когда я запускаю это на Localhost: 3000, и у меня есть http: // localhost: 3000 в авторизованном домене JS, я все еще получаю The fetch of the id assertion endpoint resulted in a network error: ERR_FAILED localhost/:1 Server did not send the correct CORS headers. main.js:26 Uncaught (in promise) IdentityCredential Error: Error retrieving a token. [/code] Как мне заставить это работать?