Byron / google-apis-rs

A binding and CLI generator for all Google APIs
http://byron.github.io/google-apis-rs
Other
983 stars 132 forks source link

AuthenticatorBuilder.subject() does not work #486

Closed cc8dea2e-4a29-4394-af6d-af0ccc73647a closed 3 months ago

cc8dea2e-4a29-4394-af6d-af0ccc73647a commented 3 months ago

Domain-wide delegation is enabled for the organisation in the Google Admin console, but a cant use AuthenticatorBuilder.subject(), i get an error - Error(GoogleApiError(MissingToken(AuthError(AuthError { error: UnauthorizedClient, error_description: Some("Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested."), error_uri: None })))).

    let gsa = oauth2::read_service_account_key("path.json").await.?;
    let auth = oauth2::ServiceAccountAuthenticator::builder(gsa)
        .subject("username@domain.name")
        .build()
        .await?;

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

I'm sure there are no problems with the access settings, because similar code in Python works.

What am I doing wrong?