https://opendal.apache.org/ logo
iCloud's REST API
# general
b
Hi.Late Happy New Year.I recently studied iCloud's REST API. I wanted to read and write DriveNode File with Rust first. I have passed two steps to verify, but some problems have no clue.
Copy code
shellError: AuthenticationFailed("{\n  \"error\": 1,\n  \"reason\": \"Missing X-APPLE-WEBAUTH-TOKEN cookie\"\n}")
.Does anyone familiar with this can provide some suggestions?Thank you in advance.
x
Wow!
However iCloud really hard to integrate, you can refer to https://github.com/picklepete/pyicloud for more ideas.
b
Yes....I am referring to https://github.com/chyroc/icloudgo writing to refactor on https://github.com/ReverentEngineer/icloud-rs .The iCloud access session is currently completed.But explore it on
iCloud Driver
(https://www.icloud.com.cn/iclouddrive/). I'm not sure if I can get files on Dirve.....
x
It's more complex if PCS also enabled: https://github.com/foxt/icloud.js/issues/4
b
.......
confused . It's strange that logging in now no longer requires me to continue with secondary verification. Is this question a bit random? As long as he doesn't require me to double check my login, I can easily read the data in the Drive.😆 😋 And now I success. https://cdn.discordapp.com/attachments/1191638858090164275/1191678914049888286/20240102174400.png?ex=65a65079&is=6593db79&hm=b65f1dd15c17409e2425365a0aee5ebd0a0f007fea06f0a354910df2ccffe461&
x
Wow, super cool!
> Is this question a bit random? Depends on iCloud's internal safety related logic.
b
I also think so, as long as we skip the second verification (currently only old users can) or due to some strange reasons? Or no longer require the client to perform secondary verification. We can read it freely without
Is there a risk of account suspension?
x
> Is there a risk of account suspension? No one knows about that.
We should clearly state in the documentation to caution against the possibility.
b
But Ci may be a problem. I don’t know what this way that I don’t need to verify again.
x
Yep
b
So do Dal still want to try this out? It is more bitter
x
Worth a try, since there are users who want icloud support.
b
Then I'm getting to work on it😀 . pls assgin for me .I may need to familiarize with dal's HTTP syntax first... In addition, my colleagues in the company are on one week's annual leave. Starting tomorrow, I have to do two jobs😫
x
Have fun!
b
Is there any way to generate frame blanks directly like go?
x
What's
frame blanks
?
b
like
go generated
x
Could you elaborate on your motivation? Why do you need this?
b
go-Storage quickly generates Backend that needs to be achieved.Of course, Rust also has different ways of writing
x
We don't have plan to add codegen in opendal yet.
b
How can we get
2FA Code
?It is temporarily generated on a trusted phone, so it cannot be written to
env
. Can we block and wait for user input?
x
No, we can't. I'm afraid that we must let users to provide the valid
dsWebAuthToken
or
trustToken
b
Let me do an experiment
yes.It is generated in the
HTTP head
of
"X-APPLE-TWOSV-TRUST-TOKEN"
. Once we use effective
TrustToken
, it will return Null
Can we have methods to serialize
APPLE authenticate Response
? I really want to read the body directly with a `Reader`method. But now
asyncbody
looks only supporting Bytes
Copy code
let body=response.into_body().data().await.ok_or(Error::AuthenticationFailed(String::from("body")))?;
            let bs=body.ok();
            let auth_info:serde_json::Value=
                serde_json::from_slice(bs.unwrap().chunk())?;
x
We can simply read them all into bytes and then deserialize using serde.
b
Our structure may be like this
Copy code
`
#[derive(Deserialize)]
pub struct iCloudWebservicesResponse {
    webservices: Map<String,drivews>,
}

pub struct drivews {
    pcsRequired: bool,
    status: String,
    url:String,
}
x
LGTM