como/como_api/src/zitadel/client.rs
kjuulh e991caef73
feat: with authorization
Signed-off-by: kjuulh <contact@kjuulh.io>
2023-05-27 13:12:29 +02:00

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())
}