#oauth2 #callback #local #cli #webhook

oneshot-oauth2-callback

Easily receive an OAuth2 code grant callback at a local address

2 unstable releases

0.2.1 Aug 18, 2023
0.2.0 Aug 18, 2023
0.1.0 Nov 20, 2022

#427 in Authentication

Download history 26/week @ 2024-02-14 29/week @ 2024-02-21 12/week @ 2024-02-28 1/week @ 2024-03-06 4/week @ 2024-03-13 17/week @ 2024-03-27 35/week @ 2024-04-03

52 downloads per month

MIT license

15KB
271 lines

oneshot-oauth2-callback

Crates.io docs.rs GitHub

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.

Use

// 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

lib.rs:

oneshot-auth2-callback

Dependencies

~6–23MB
~396K SLoC