You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently working with a fork of yup-oauth2 modified for another service and I wanted to upstream the changes and use the vanilla version.
Here is the basic usage of device-auth.
let ssl = hyper_native_tls::NativeTlsClient::new().unwrap();
let connector = hyper::net::HttpsConnector::new(ssl);
let client = hyper::Client::with_connector(connector);
match oauth2::Authenticator::new(&secret, StdoutHandler, client,
oauth2::NullStorage,
Some(oauth2::FlowType::Device(String::from("https://deviceurl")))).token(&scope) {
Ok(t) => {
println!("Authentication granted!");
println!("You should store the following information for use, or revoke it.");
println!("All dates are given in UTC.");
println!("{:?}", t);
},
Err(err) => {
println!("Access token wasn't obtained: {}", err);
std::process::exit(10);
}
}
I see the trait Flow with the function type_id implemented for DeviceFlow
I first noticed that I can't use DeviceFlow as though it was a FlowType::Device
So I exported Flow in lib.rs
diff --git a/src/lib.rs b/src/lib.rs
index 38500f7..a6aff23 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -96,7 +96,7 @@ mod types;
pub use device::{GOOGLE_DEVICE_CODE_URL, DeviceFlow};
pub use refresh::{RefreshFlow, RefreshResult};
-pub use types::{Token, FlowType, ApplicationSecret, ConsoleApplicationSecret, Scheme, TokenType};
+pub use types::{Token, Flow, FlowType, ApplicationSecret, ConsoleApplicationSecret, Scheme, TokenType};
pub use installed::{InstalledFlow, InstalledFlowReturnMethod};
pub use storage::{TokenStorage, NullStorage, MemoryStorage, DiskTokenStorage};
pub use authenticator::{Authenticator, Retry, GetToken};
I want to use it in this way
use oauth2::Flow;
let ssl = hyper_native_tls::NativeTlsClient::new().unwrap();
let connector = hyper::net::HttpsConnector::new(ssl);
let client = hyper::Client::with_connector(connector);
let mut flow = oauth2::DeviceFlow::new_device(client, &secret,
String::from("https://login.devicecode/blah"), Some(String::from("device_code")));
match oauth2::Authenticator::new(&secret, StdoutHandler, client,·
oauth2::NullStorage, Some(flow.type_id())).token(&scope) {
the function new_device is a modification of new with an added Option<String> so that we can set the grant_type. If no String is passed we default to http://oauth.net/grant_type/device/1.0 to keep the original functionality and new just wraps around this without passing the 4th argument.
My current error is
error: no method named `type_id` found for type `oauth2::DeviceFlow<hyper::Client>` in the current scope
note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: candidate #1 is defined in the trait `oauth2::Flow`
I haven't being using rust more then a week or so so I could be wrong but I assume I am trying to use this Trait in the correct manner?
The text was updated successfully, but these errors were encountered:
Thanks @dermesser.
Going to close this because I had since learned we can not override in rust in the way I expected.
Thanks for the explanation on the type_id
Hey guys,
Currently working with a fork of yup-oauth2 modified for another service and I wanted to upstream the changes and use the vanilla version.
Here is the basic usage of device-auth.
I see the trait
Flow
with the functiontype_id
implemented forDeviceFlow
I first noticed that I can't use
DeviceFlow
as though it was aFlowType::Device
So I exported
Flow
inlib.rs
I want to use it in this way
the function
new_device
is a modification ofnew
with an addedOption<String>
so that we can set thegrant_type
. If no String is passed we default tohttp://oauth.net/grant_type/device/1.0
to keep the original functionality andnew
just wraps around this without passing the 4th argument.My current error is
I haven't being using rust more then a week or so so I could be wrong but I assume I am trying to use this
Trait
in the correct manner?The text was updated successfully, but these errors were encountered: