Skip to content
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

JsonDecodeError For GenerateRandomBytesRequest #455

Open
SpadeA-Tang opened this issue Nov 28, 2023 · 2 comments
Open

JsonDecodeError For GenerateRandomBytesRequest #455

SpadeA-Tang opened this issue Nov 28, 2023 · 2 comments

Comments

@SpadeA-Tang
Copy link

It seems desearialize json is failed. The code is listed below and would you mind giving some feedbacks whether the code is inappropriate?

Err(JsonDecodeError("{\n \"data\": \"re9uM3jHgyBO55Bb5thfEc51X7qdvTFlTmYPDWU07rvSLXwKTXVQIecmyOtmjgrdH0RE+/LZ0XKNtiJKoLbm3y6+D3PWQHcmq6OgguWuQxJ23drOhypxfZdXaN2o1+xz7T31TVPqOnm3zlp8z4wtsR6cVupxgzYb5zguv5EQ73I=\",\n \"dataCrc32c\": \"589474822\"\n}\n", Error("Invalid byte 43, offset 68.", line: 2, column: 184)))

#[tokio::main]
async fn main() {
    let secret = yup_oauth2::read_authorized_user_secret(
        "/home/spadea/.config/gcloud/application_default_credentials.json",
    )
    .await
    .unwrap();

    let auth = AuthorizedUserAuthenticator::builder(secret)
        .build()
        .await
        .unwrap();

    let hub = CloudKMS::new(
        hyper::Client::builder().build(
            hyper_rustls::HttpsConnectorBuilder::new()
                .with_native_roots()
                .https_or_http()
                .enable_http1()
                .build(),
        ),
        auth,
    );

    let mut req = GenerateRandomBytesRequest::default();
    req.length_bytes = Some(128);
    req.protection_level = Some(String::from("HSM"));
    let result = hub
        .projects()
        .locations_generate_random_bytes(req, "projects/xxx/locations/xxx")
        .doit()
        .await;

    println!("{:?}", result);
}
@Byron
Copy link
Owner

Byron commented Nov 28, 2023

It's a problem with it trying to decode that JSON with data being base64 encoded into binary data, as declared in the datatype.

Its probably related to one of the many issues related to confused URL/Base64 encoding. The problem is that it's unclear how to figure out the kind of encoding just by looking at the API description, and thus far nobody was able to contribute a fix.

@SpadeA-Tang
Copy link
Author

SpadeA-Tang commented Nov 28, 2023

It's a problem with it trying to decode that JSON with data being base64 encoded into binary data, as declared in the datatype.

Its probably related to one of the many issues related to confused URL/Base64 encoding. The problem is that it's unclear how to figure out the kind of encoding just by looking at the API description, and thus far nobody was able to contribute a fix.

Thanks for the reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants