Crates.io | oneshot-oauth2-callback |
lib.rs | oneshot-oauth2-callback |
version | 0.2.1 |
source | src |
created_at | 2022-11-20 01:38:10.654888 |
updated_at | 2023-08-18 16:56:02.523423 |
description | Easily receive an OAuth2 code grant callback at a local address. |
homepage | |
repository | https://github.com/tommilligan/oneshot-oauth2-callback |
max_upload_size | |
id | 718860 |
size | 17,577 |
Easily receive an OAuth2 code grant callback at a local address.
Useful for command-line tools needing to perform an OAuth2 flow, or for development/testing of more complex flows.
// Bind the listener to local port
let address = std::net::SocketAddr::from(([127, 0, 0, 1], 5000));
// Listen for the first OAuth2 response, then immediately shutdown and return
let code_grant = oneshot_oauth2_callback::oneshot(&address)
.await
.expect("oauth2 login failed");
// use code_grant.code, code_grant.state.secret() to continue the flow