Skip to content

JsonDecodeError For GenerateRandomBytesRequest #455

@SpadeA-Tang

Description

@SpadeA-Tang

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);
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions