21 lines
787 B
Rust
21 lines
787 B
Rust
use oauth2::{basic::BasicClient, AuthUrl, ClientId, ClientSecret, RedirectUrl, TokenUrl};
|
|
use std::env;
|
|
|
|
pub fn oauth_client() -> BasicClient {
|
|
let client_id = env::var("CLIENT_ID").expect("Missing CLIENT_ID!");
|
|
let client_secret = env::var("CLIENT_SECRET").expect("Missing CLIENT_SECRET!");
|
|
let redirect_url = env::var("REDIRECT_URL").expect("missing REDIRECT_URL");
|
|
|
|
let auth_url = env::var("AUTH_URL").expect("missing AUTH_URL");
|
|
|
|
let token_url = env::var("TOKEN_URL").expect("missing TOKEN_URL");
|
|
|
|
BasicClient::new(
|
|
ClientId::new(client_id),
|
|
Some(ClientSecret::new(client_secret)),
|
|
AuthUrl::new(auth_url).unwrap(),
|
|
Some(TokenUrl::new(token_url).unwrap()),
|
|
)
|
|
.set_redirect_uri(RedirectUrl::new(redirect_url).unwrap())
|
|
}
|