-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot fetch calendar from caldav.icloud.com #238
Comments
I'm in the same boat, still trying to diagnose the issue. |
@cmdr-dmoondra Reverting back to version 2.1.2 seems to fix the issue. |
I "fixed" it. iCloud does not like the First, add a const client = new DAVClient({
// ...
fetchOptions: {
headers: {
"Accept-Encoding": null as unknown as string,
"Accept-Language": null as unknown as string,
}
}
}); ( Then, edit the library code. For me, the called file was in Look for headers: {
"Content-Type": "application/xml",
...cleanupFalsy(headers),
}, with headers: Object.assign({
"Content-Type": "application/xml",
...cleanupFalsy(headers),
}, fetchOptions.headers), Now the requests should work, they succeeded for me. @natelindev Please make |
When calling fetchPrincipalUrl, the HTTP header will add "accept-language: *" by default, which will cause Apple to return Internal Server Error. However, if it is not *, no error will occur. To avoid this problem, there are two temporary solutions: low level api: import { fetchPrincipalUrl, getBasicAuthHeaders } from "tsdav";
(async () => {
const principalUrl = await fetchPrincipalUrl({
account: {
serverUrl: "https://caldav.icloud.com.cn",
rootUrl: "https://caldav.icloud.com.cn",
accountType: "caldav",
},
headers: {
...getBasicAuthHeaders({
username: "{ your account id }",
password: "{ your password }",
}),
"accept-language": "zh-CN,en;q=0.5", // add "accept-language" field. Perhaps you should set this value according to your actual situation
},
});
})(); or client api: import { createDAVClient, getBasicAuthHeaders } from "tsdav";
(async () => {
const client = await createDAVClient({
serverUrl: "https://caldav.icloud.com.cn",
credentials: {
username: "{ your account id }",
password: "{ your password }",
},
authMethod: "Custom", // Important use Custom
defaultAccountType: "caldav",
authFunction: async (credentials) => {
return {
...getBasicAuthHeaders(credentials),
"accept-language": "zh-CN,en;q=0.5", // add "accept-language" field. Perhaps you should set this value according to your actual situation
};
},
});
const calendars = await client.fetchCalendars();
console.log(calendars);
})(); Note: The above code has only been tested on https://caldav.icloud.com.cn/ (This is a host serving Chinese customers), and not sure if other Apple hosts are available |
So That said, only changing |
I am unable to fetch the data from caldav.icloud.com, always getting the error for "cannot find homeUrl"
I am using this approach,
const client = new DAVClient({
serverUrl: 'https://caldav.icloud.com',
credentials: {
username: '[email protected]',
password: 'xxx',
},
authMethod: 'Basic',
defaultAccountType: 'caldav',
});
and after this when i call the await client.login(); i get the error saying -> "cannot find homeUrl"
The text was updated successfully, but these errors were encountered: