oauth_axum/providers/microsoft.rs
1use crate::CustomProvider;
2
3pub struct MicrosoftProvider {}
4
5impl MicrosoftProvider {
6 /// Create a new MicrosoftProvider
7 ///
8 /// # Arguments
9 /// * `tenant_id` - The tenant id - Check Microsfot docmentation for more information: https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow#request-an-authorization-code
10 /// * `client_id` - The client id
11 /// * `client_secret` - The client secret
12 /// * `redirect_url` - The redirect url
13 ///
14 pub fn new(
15 tenant_id: String,
16 client_id: String,
17 client_secret: String,
18 redirect_url: String,
19 ) -> CustomProvider {
20 let base_url = String::from(
21 "https://login.microsoftonline.com/".to_string() + tenant_id.as_str() + "/oauth2/v2.0",
22 );
23 CustomProvider::new(
24 String::from(base_url.clone() + "/authorize"),
25 String::from(base_url + "/token"),
26 client_id,
27 client_secret,
28 redirect_url,
29 )
30 }
31}