-
Notifications
You must be signed in to change notification settings - Fork 14
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
Authentication examples #24
Comments
I see there are some CLI apps in the |
Yeah authentication is a tricky part of the setup. I can see if I can add an example, but in the meantime, we use version It should look something like: [dependencies]
google_api_auth = { git = "https://github.com/google-apis-rs/generator.git", features = ["with-yup-oauth2"] }
google_storage = { git = "https://github.com/google-apis-rs/generated.git", package = "google-storage1" }
yup-oauth2 = "3" let creds_file = env::var("GOOGLE_APPLICATION_CREDENTIALS")
.expect("GOOGLE_APPLICATION_CREDENTIALS environment variable");
let credentials = yup_oauth2::service_account_key_from_file(creds_file)
.expect("valid GOOGLE_APPLICATION_CREDENTIALS");
let auth = google_api_auth::yup_oauth2::from_authenticator(
yup_oauth2::ServiceAccountAccess::new(credentials).build(),
vec!["https://www.googleapis.com/auth/devstorage.full_control"],
);
let storage_client = google_storage::Client::new(auth); Finding the FYI I have had trouble pinning the dependencies to a specific git SHA, which I am pretty sure has to do with the fact that auth uses (dynamic) trait objects. Obviously this is a little rough around the edges right now and should get easier in the future. Specifically, I want to try to add support for Google Application Default Credentials auth flow (dermesser/yup-oauth2#110) Also, the API will probably change slightly as we move to |
All that being said, I just noticed you wanted a Google calendar app example, which isn't a Google Cloud API so the auth flow will be different. My bad! 🙃 You will probably want to do an oauth2 flow for authenticating https://developers.google.com/identity/protocols/oauth2. This yup-oauth2 example might be what you are looking for? I have only used Google Cloud APIs, so I might not be a ton of help, but I can try to help you if you get stuck. |
Hey William, thank you for the information. Will check it. Google Calendar was just an example, even though I think it is a Google API. In any case, will check yup-oauth2 as you suggested. |
This example no longer compiles:
|
How would an API that only needs an API key be used? |
It would be very useful to have a reference implementation of one of the generated (e.g. Cloud) APIs to provide guidance to those of us noobs who struggle to use this repo. I'm also affected by the auth example in this issue no longer compiling. I tried to understand how drmesser's example here It appears that |
First of all, thank you, this is an extremely useful project!
I am wondering if there are any examples to demonstrate how to use the generated libraries. E.g. a small cli app that lists events from a Google calendar or something similar. 🙏
The text was updated successfully, but these errors were encountered: