The library currently supports Google OAuth2 flow for installed desktop applications and has been initally tested with manual copy/paste (of authorization code) redirect method.
Going forward support for Loopback IP redirect is planned to be added.
Credentials
> Create credentials
> OAuth client ID
Other
Download JSON
configuration of newly created application toml
[dependencies]
gauth = "0.3.1"
Sample client implementation
```rust,norun
fn main() {
// define consent URL handler
// returns an auth. code which is then exchanged against access token
let handleauth = |consenturl: String| -> Result
let mut auth_code = String::new();
io::stdin().read_line(&mut auth_code)?;
Ok(auth_code)
}
let auth_client = gauth::Auth::new(
"my-new-application",
&[
"https://www.googleapis.com/auth/drive.readonly",
],
PathBuf::from("/my-google-credentials/oauth-credentials.json"),
);
let token = auth_client
.access_token(handle_auth)
.expect("failed to retrieve access token");
println!("obtained token: {:?}", token);
} ```
License under either or: