examples: Update to oauth2 5 (#3462)

This commit is contained in:
tottoto
2025-09-11 15:34:41 +02:00
committed by GitHub
parent 5d5ba01be9
commit e4550d23b1
4 changed files with 90 additions and 233 deletions
Generated
+69 -216
View File
@@ -314,10 +314,10 @@ dependencies = [
"futures-core", "futures-core",
"futures-sink", "futures-sink",
"futures-util", "futures-util",
"http 1.2.0", "http",
"http-body 1.0.1", "http-body",
"http-body-util", "http-body-util",
"hyper 1.5.2", "hyper",
"hyper-util", "hyper-util",
"itoa", "itoa",
"matchit", "matchit",
@@ -328,13 +328,13 @@ dependencies = [
"pin-project-lite", "pin-project-lite",
"quickcheck", "quickcheck",
"quickcheck_macros", "quickcheck_macros",
"reqwest 0.12.12", "reqwest",
"serde", "serde",
"serde_json", "serde_json",
"serde_path_to_error", "serde_path_to_error",
"serde_urlencoded", "serde_urlencoded",
"sha1", "sha1",
"sync_wrapper 1.0.2", "sync_wrapper",
"time", "time",
"tokio", "tokio",
"tokio-stream", "tokio-stream",
@@ -357,14 +357,14 @@ dependencies = [
"axum-macros", "axum-macros",
"bytes", "bytes",
"futures-core", "futures-core",
"http 1.2.0", "http",
"http-body 1.0.1", "http-body",
"http-body-util", "http-body-util",
"hyper 1.5.2", "hyper",
"mime", "mime",
"pin-project-lite", "pin-project-lite",
"rustversion", "rustversion",
"sync_wrapper 1.0.2", "sync_wrapper",
"tokio", "tokio",
"tower-http 0.6.2", "tower-http 0.6.2",
"tower-layer", "tower-layer",
@@ -386,16 +386,16 @@ dependencies = [
"futures-core", "futures-core",
"futures-util", "futures-util",
"headers", "headers",
"http 1.2.0", "http",
"http-body 1.0.1", "http-body",
"http-body-util", "http-body-util",
"hyper 1.5.2", "hyper",
"mime", "mime",
"multer", "multer",
"percent-encoding", "percent-encoding",
"pin-project-lite", "pin-project-lite",
"prost", "prost",
"reqwest 0.12.12", "reqwest",
"rustversion", "rustversion",
"serde", "serde",
"serde_html_form", "serde_html_form",
@@ -438,10 +438,10 @@ dependencies = [
"arc-swap", "arc-swap",
"bytes", "bytes",
"futures-util", "futures-util",
"http 1.2.0", "http",
"http-body 1.0.1", "http-body",
"http-body-util", "http-body-util",
"hyper 1.5.2", "hyper",
"hyper-util", "hyper-util",
"pin-project-lite", "pin-project-lite",
"rustls 0.21.12", "rustls 0.21.12",
@@ -461,10 +461,10 @@ dependencies = [
"arc-swap", "arc-swap",
"bytes", "bytes",
"futures-util", "futures-util",
"http 1.2.0", "http",
"http-body 1.0.1", "http-body",
"http-body-util", "http-body-util",
"hyper 1.5.2", "hyper",
"hyper-util", "hyper-util",
"pin-project-lite", "pin-project-lite",
"rustls 0.23.20", "rustls 0.23.20",
@@ -1357,7 +1357,7 @@ dependencies = [
"axum", "axum",
"brotli 6.0.0", "brotli 6.0.0",
"flate2", "flate2",
"http 1.2.0", "http",
"serde_json", "serde_json",
"tokio", "tokio",
"tower 0.5.2", "tower 0.5.2",
@@ -1504,7 +1504,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"axum", "axum",
"http-body-util", "http-body-util",
"hyper 1.5.2", "hyper",
"tokio", "tokio",
"tower 0.5.2", "tower 0.5.2",
] ]
@@ -1522,7 +1522,7 @@ name = "example-http-proxy"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"axum", "axum",
"hyper 1.5.2", "hyper",
"hyper-util", "hyper-util",
"tokio", "tokio",
"tower 0.5.2", "tower 0.5.2",
@@ -1561,7 +1561,7 @@ name = "example-low-level-native-tls"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"axum", "axum",
"hyper 1.5.2", "hyper",
"hyper-util", "hyper-util",
"tokio", "tokio",
"tokio-native-tls", "tokio-native-tls",
@@ -1575,7 +1575,7 @@ name = "example-low-level-openssl"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"axum", "axum",
"hyper 1.5.2", "hyper",
"hyper-util", "hyper-util",
"openssl", "openssl",
"tokio", "tokio",
@@ -1590,7 +1590,7 @@ name = "example-low-level-rustls"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"axum", "axum",
"hyper 1.5.2", "hyper",
"hyper-util", "hyper-util",
"tokio", "tokio",
"tokio-rustls 0.26.1", "tokio-rustls 0.26.1",
@@ -1631,9 +1631,9 @@ dependencies = [
"async-session", "async-session",
"axum", "axum",
"axum-extra", "axum-extra",
"http 1.2.0", "http",
"oauth2", "oauth2",
"reqwest 0.12.12", "reqwest",
"serde", "serde",
"tokio", "tokio",
"tracing", "tracing",
@@ -1713,7 +1713,7 @@ name = "example-reqwest-response"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"axum", "axum",
"reqwest 0.12.12", "reqwest",
"tokio", "tokio",
"tokio-stream", "tokio-stream",
"tower-http 0.6.2", "tower-http 0.6.2",
@@ -1726,7 +1726,7 @@ name = "example-reverse-proxy"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"axum", "axum",
"hyper 1.5.2", "hyper",
"hyper-util", "hyper-util",
"tokio", "tokio",
] ]
@@ -1744,7 +1744,7 @@ name = "example-serve-with-hyper"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"axum", "axum",
"hyper 1.5.2", "hyper",
"hyper-util", "hyper-util",
"tokio", "tokio",
"tower 0.5.2", "tower 0.5.2",
@@ -1757,7 +1757,7 @@ dependencies = [
"axum", "axum",
"axum-extra", "axum-extra",
"futures-executor", "futures-executor",
"http 1.2.0", "http",
"tower-service", "tower-service",
] ]
@@ -1781,7 +1781,7 @@ dependencies = [
"eventsource-stream", "eventsource-stream",
"futures-util", "futures-util",
"headers", "headers",
"reqwest 0.12.12", "reqwest",
"reqwest-eventsource", "reqwest-eventsource",
"tokio", "tokio",
"tokio-stream", "tokio-stream",
@@ -1944,7 +1944,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"axum", "axum",
"http-body-util", "http-body-util",
"hyper 1.5.2", "hyper",
"hyper-util", "hyper-util",
"tokio", "tokio",
"tracing-subscriber", "tracing-subscriber",
@@ -2226,25 +2226,6 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2"
[[package]]
name = "h2"
version = "0.3.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8"
dependencies = [
"bytes",
"fnv",
"futures-core",
"futures-sink",
"futures-util",
"http 0.2.12",
"indexmap 2.7.0",
"slab",
"tokio",
"tokio-util",
"tracing",
]
[[package]] [[package]]
name = "h2" name = "h2"
version = "0.4.7" version = "0.4.7"
@@ -2256,7 +2237,7 @@ dependencies = [
"fnv", "fnv",
"futures-core", "futures-core",
"futures-sink", "futures-sink",
"http 1.2.0", "http",
"indexmap 2.7.0", "indexmap 2.7.0",
"slab", "slab",
"tokio", "tokio",
@@ -2314,7 +2295,7 @@ dependencies = [
"base64 0.21.7", "base64 0.21.7",
"bytes", "bytes",
"headers-core", "headers-core",
"http 1.2.0", "http",
"httpdate", "httpdate",
"mime", "mime",
"sha1", "sha1",
@@ -2326,7 +2307,7 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4" checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4"
dependencies = [ dependencies = [
"http 1.2.0", "http",
] ]
[[package]] [[package]]
@@ -2440,17 +2421,6 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "http"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1"
dependencies = [
"bytes",
"fnv",
"itoa",
]
[[package]] [[package]]
name = "http" name = "http"
version = "1.2.0" version = "1.2.0"
@@ -2462,17 +2432,6 @@ dependencies = [
"itoa", "itoa",
] ]
[[package]]
name = "http-body"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2"
dependencies = [
"bytes",
"http 0.2.12",
"pin-project-lite",
]
[[package]] [[package]]
name = "http-body" name = "http-body"
version = "1.0.1" version = "1.0.1"
@@ -2480,7 +2439,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184"
dependencies = [ dependencies = [
"bytes", "bytes",
"http 1.2.0", "http",
] ]
[[package]] [[package]]
@@ -2491,8 +2450,8 @@ checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures-core", "futures-core",
"http 1.2.0", "http",
"http-body 1.0.1", "http-body",
"pin-project-lite", "pin-project-lite",
] ]
@@ -2523,30 +2482,6 @@ dependencies = [
"libm", "libm",
] ]
[[package]]
name = "hyper"
version = "0.14.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7"
dependencies = [
"bytes",
"futures-channel",
"futures-core",
"futures-util",
"h2 0.3.26",
"http 0.2.12",
"http-body 0.4.6",
"httparse",
"httpdate",
"itoa",
"pin-project-lite",
"socket2",
"tokio",
"tower-service",
"tracing",
"want",
]
[[package]] [[package]]
name = "hyper" name = "hyper"
version = "1.5.2" version = "1.5.2"
@@ -2556,9 +2491,9 @@ dependencies = [
"bytes", "bytes",
"futures-channel", "futures-channel",
"futures-util", "futures-util",
"h2 0.4.7", "h2",
"http 1.2.0", "http",
"http-body 1.0.1", "http-body",
"httparse", "httparse",
"httpdate", "httpdate",
"itoa", "itoa",
@@ -2568,20 +2503,6 @@ dependencies = [
"want", "want",
] ]
[[package]]
name = "hyper-rustls"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590"
dependencies = [
"futures-util",
"http 0.2.12",
"hyper 0.14.32",
"rustls 0.21.12",
"tokio",
"tokio-rustls 0.24.1",
]
[[package]] [[package]]
name = "hyper-rustls" name = "hyper-rustls"
version = "0.27.5" version = "0.27.5"
@@ -2589,8 +2510,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2"
dependencies = [ dependencies = [
"futures-util", "futures-util",
"http 1.2.0", "http",
"hyper 1.5.2", "hyper",
"hyper-util", "hyper-util",
"rustls 0.23.20", "rustls 0.23.20",
"rustls-pki-types", "rustls-pki-types",
@@ -2608,7 +2529,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0"
dependencies = [ dependencies = [
"bytes", "bytes",
"http-body-util", "http-body-util",
"hyper 1.5.2", "hyper",
"hyper-util", "hyper-util",
"native-tls", "native-tls",
"tokio", "tokio",
@@ -2625,9 +2546,9 @@ dependencies = [
"bytes", "bytes",
"futures-channel", "futures-channel",
"futures-util", "futures-util",
"http 1.2.0", "http",
"http-body 1.0.1", "http-body",
"hyper 1.5.2", "hyper",
"pin-project-lite", "pin-project-lite",
"socket2", "socket2",
"tokio", "tokio",
@@ -3238,7 +3159,7 @@ dependencies = [
"bytes", "bytes",
"encoding_rs", "encoding_rs",
"futures-util", "futures-util",
"http 1.2.0", "http",
"httparse", "httparse",
"memchr", "memchr",
"mime", "mime",
@@ -3357,16 +3278,16 @@ dependencies = [
[[package]] [[package]]
name = "oauth2" name = "oauth2"
version = "4.4.2" version = "5.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c38841cdd844847e3e7c8d29cef9dcfed8877f8f56f9071f77843ecf3baf937f" checksum = "51e219e79014df21a225b1860a479e2dcd7cbd9130f4defd4bd0e191ea31d67d"
dependencies = [ dependencies = [
"base64 0.13.1", "base64 0.22.1",
"chrono", "chrono",
"getrandom 0.2.15", "getrandom 0.2.15",
"http 0.2.12", "http",
"rand 0.8.5", "rand 0.8.5",
"reqwest 0.11.27", "reqwest",
"serde", "serde",
"serde_json", "serde_json",
"serde_path_to_error", "serde_path_to_error",
@@ -3967,47 +3888,6 @@ version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]]
name = "reqwest"
version = "0.11.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62"
dependencies = [
"base64 0.21.7",
"bytes",
"encoding_rs",
"futures-core",
"futures-util",
"h2 0.3.26",
"http 0.2.12",
"http-body 0.4.6",
"hyper 0.14.32",
"hyper-rustls 0.24.2",
"ipnet",
"js-sys",
"log",
"mime",
"once_cell",
"percent-encoding",
"pin-project-lite",
"rustls 0.21.12",
"rustls-pemfile 1.0.4",
"serde",
"serde_json",
"serde_urlencoded",
"sync_wrapper 0.1.2",
"system-configuration 0.5.1",
"tokio",
"tokio-rustls 0.24.1",
"tower-service",
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"webpki-roots 0.25.4",
"winreg",
]
[[package]] [[package]]
name = "reqwest" name = "reqwest"
version = "0.12.12" version = "0.12.12"
@@ -4019,12 +3899,12 @@ dependencies = [
"encoding_rs", "encoding_rs",
"futures-core", "futures-core",
"futures-util", "futures-util",
"h2 0.4.7", "h2",
"http 1.2.0", "http",
"http-body 1.0.1", "http-body",
"http-body-util", "http-body-util",
"hyper 1.5.2", "hyper",
"hyper-rustls 0.27.5", "hyper-rustls",
"hyper-tls", "hyper-tls",
"hyper-util", "hyper-util",
"ipnet", "ipnet",
@@ -4043,8 +3923,8 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
"sync_wrapper 1.0.2", "sync_wrapper",
"system-configuration 0.6.1", "system-configuration",
"tokio", "tokio",
"tokio-native-tls", "tokio-native-tls",
"tokio-rustls 0.26.1", "tokio-rustls 0.26.1",
@@ -4072,7 +3952,7 @@ dependencies = [
"mime", "mime",
"nom", "nom",
"pin-project-lite", "pin-project-lite",
"reqwest 0.12.12", "reqwest",
"thiserror 1.0.69", "thiserror 1.0.69",
] ]
@@ -4853,12 +4733,6 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "sync_wrapper"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
[[package]] [[package]]
name = "sync_wrapper" name = "sync_wrapper"
version = "1.0.2" version = "1.0.2"
@@ -4879,17 +4753,6 @@ dependencies = [
"syn 2.0.93", "syn 2.0.93",
] ]
[[package]]
name = "system-configuration"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7"
dependencies = [
"bitflags 1.3.2",
"core-foundation",
"system-configuration-sys 0.5.0",
]
[[package]] [[package]]
name = "system-configuration" name = "system-configuration"
version = "0.6.1" version = "0.6.1"
@@ -4898,17 +4761,7 @@ checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"core-foundation", "core-foundation",
"system-configuration-sys 0.6.0", "system-configuration-sys",
]
[[package]]
name = "system-configuration-sys"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9"
dependencies = [
"core-foundation-sys",
"libc",
] ]
[[package]] [[package]]
@@ -5261,7 +5114,7 @@ dependencies = [
"indexmap 2.7.0", "indexmap 2.7.0",
"pin-project-lite", "pin-project-lite",
"slab", "slab",
"sync_wrapper 1.0.2", "sync_wrapper",
"tokio", "tokio",
"tokio-util", "tokio-util",
"tower-layer", "tower-layer",
@@ -5278,8 +5131,8 @@ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"bytes", "bytes",
"futures-util", "futures-util",
"http 1.2.0", "http",
"http-body 1.0.1", "http-body",
"http-body-util", "http-body-util",
"http-range-header", "http-range-header",
"httpdate", "httpdate",
@@ -5307,8 +5160,8 @@ dependencies = [
"bytes", "bytes",
"futures-core", "futures-core",
"futures-util", "futures-util",
"http 1.2.0", "http",
"http-body 1.0.1", "http-body",
"http-body-util", "http-body-util",
"http-range-header", "http-range-header",
"httpdate", "httpdate",
@@ -5442,7 +5295,7 @@ checksum = "eadc29d668c91fcc564941132e17b28a7ceb2f3ebf0b9dae3e03fd7a6748eb0d"
dependencies = [ dependencies = [
"bytes", "bytes",
"data-encoding", "data-encoding",
"http 1.2.0", "http",
"httparse", "httparse",
"log", "log",
"rand 0.9.1", "rand 0.9.1",
-4
View File
@@ -25,8 +25,6 @@ skip-tree = [
{ name = "spin" }, { name = "spin" },
# lots still pulls in syn 1.x # lots still pulls in syn 1.x
{ name = "syn" }, { name = "syn" },
# until 1.0 is out we're pulling in both 0.14 and 1.0-rc.x
{ name = "hyper" },
# pulled in by tracing-subscriber # pulled in by tracing-subscriber
{ name = "regex-syntax" }, { name = "regex-syntax" },
# pulled in by tracing-subscriber # pulled in by tracing-subscriber
@@ -36,8 +34,6 @@ skip-tree = [
# hyper-util hasn't upgraded to 0.5 yet, but it's the same service / layer # hyper-util hasn't upgraded to 0.5 yet, but it's the same service / layer
# crates beneath # crates beneath
{ name = "tower" }, { name = "tower" },
# tower hasn't upgraded to 1.0 yet
{ name = "sync_wrapper" },
# pulled in by quickcheck and cookie # pulled in by quickcheck and cookie
{ name = "rand" }, { name = "rand" },
] ]
+1 -1
View File
@@ -10,7 +10,7 @@ async-session = "3.0.0"
axum = { path = "../../axum" } axum = { path = "../../axum" }
axum-extra = { path = "../../axum-extra", features = ["typed-header"] } axum-extra = { path = "../../axum-extra", features = ["typed-header"] }
http = "1.0.0" http = "1.0.0"
oauth2 = "4.1" oauth2 = "5"
# Use Rustls because it makes it easier to cross-compile on CI # Use Rustls because it makes it easier to cross-compile on CI
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "json"] } reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "json"] }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
+20 -12
View File
@@ -20,8 +20,8 @@ use axum::{
use axum_extra::{headers, typed_header::TypedHeaderRejectionReason, TypedHeader}; use axum_extra::{headers, typed_header::TypedHeaderRejectionReason, TypedHeader};
use http::{header, request::Parts, StatusCode}; use http::{header, request::Parts, StatusCode};
use oauth2::{ use oauth2::{
basic::BasicClient, reqwest::async_http_client, AuthUrl, AuthorizationCode, ClientId, AuthUrl, AuthorizationCode, ClientId, ClientSecret, CsrfToken, EndpointNotSet, EndpointSet,
ClientSecret, CsrfToken, RedirectUrl, Scope, TokenResponse, TokenUrl, RedirectUrl, Scope, TokenResponse, TokenUrl,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{convert::Infallible, env}; use std::{convert::Infallible, env};
@@ -30,6 +30,14 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
static COOKIE_NAME: &str = "SESSION"; static COOKIE_NAME: &str = "SESSION";
static CSRF_TOKEN: &str = "csrf_token"; static CSRF_TOKEN: &str = "csrf_token";
type BasicClient = oauth2::basic::BasicClient<
EndpointSet,
EndpointNotSet,
EndpointNotSet,
EndpointNotSet,
EndpointSet,
>;
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
tracing_subscriber::registry() tracing_subscriber::registry()
@@ -110,15 +118,15 @@ fn oauth_client() -> Result<BasicClient, AppError> {
let token_url = env::var("TOKEN_URL") let token_url = env::var("TOKEN_URL")
.unwrap_or_else(|_| "https://discord.com/api/oauth2/token".to_string()); .unwrap_or_else(|_| "https://discord.com/api/oauth2/token".to_string());
Ok(BasicClient::new( Ok(oauth2::basic::BasicClient::new(ClientId::new(client_id))
ClientId::new(client_id), .set_client_secret(ClientSecret::new(client_secret))
Some(ClientSecret::new(client_secret)), .set_auth_uri(
AuthUrl::new(auth_url).context("failed to create new authorization server URL")?, AuthUrl::new(auth_url).context("failed to create new authorization server URL")?,
Some(TokenUrl::new(token_url).context("failed to create new token endpoint URL")?), )
) .set_token_uri(TokenUrl::new(token_url).context("failed to create new token endpoint URL")?)
.set_redirect_uri( .set_redirect_uri(
RedirectUrl::new(redirect_url).context("failed to create new redirection URL")?, RedirectUrl::new(redirect_url).context("failed to create new redirection URL")?,
)) ))
} }
// The user data we'll get back from Discord. // The user data we'll get back from Discord.
@@ -265,7 +273,7 @@ async fn login_authorized(
// Get an auth token // Get an auth token
let token = oauth_client let token = oauth_client
.exchange_code(AuthorizationCode::new(query.code.clone())) .exchange_code(AuthorizationCode::new(query.code.clone()))
.request_async(async_http_client) .request_async(&reqwest::Client::new())
.await .await
.context("failed in sending request request to authorization server")?; .context("failed in sending request request to authorization server")?;