graph_oauth/
lib.rs

1//! # Microsoft Identity Platform Client
2//!
3//! Support For OAuth 2.0 and OpenId authorization flows from the Microsoft Identity Platform.
4//!
5//! Part of the [graph-rs-sdk](https://crates.io/crates/graph-rs-sdk) project on [GitHub](https://crates.io/crates/graph-rs-sdk)
6//!
7//!
8//! # Example ConfidentialClientApplication Authorization Code Flow
9//! ```rust
10//! use url::Url;
11//! use graph_oauth::{AuthorizationCodeCredential, ConfidentialClientApplication};
12//!
13//! pub fn authorization_url(client_id: &str) -> anyhow::Result<Url> {
14//!     Ok(ConfidentialClientApplication::builder(client_id)
15//!         .auth_code_url_builder()
16//!         .with_redirect_uri(Url::parse("http://localhost:8000/redirect")?)
17//!         .with_scope(vec!["user.read"])
18//!         .url()?)
19//! }
20//!
21//! pub fn get_confidential_client(authorization_code: &str, client_id: &str, client_secret: &str) -> anyhow::Result<ConfidentialClientApplication<AuthorizationCodeCredential>> {
22//!     Ok(ConfidentialClientApplication::builder(client_id)
23//!         .with_auth_code(authorization_code)
24//!         .with_client_secret(client_secret)
25//!         .with_scope(vec!["user.read"])
26//!         .with_redirect_uri(Url::parse("http://localhost:8000/redirect")?)
27//!         .build())
28//! }
29//! ```
30//! #### Supported Authorization Flows From The Microsoft Identity Platform
31//!
32//! - [Authorization Code Grant](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow)
33//! - [Authorization Code Grant PKCE](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow)
34//! - [Authorization Code Certificate](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow#request-an-access-token-with-a-certificate-credential)
35//! - [Open ID Connect](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-protocols-oidc)
36//! - [Implicit Grant](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-implicit-grant-flow)
37//! - [Device Code Flow](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code)
38//! - [Client Credentials - Client Secret](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow#first-case-access-token-request-with-a-shared-secret)
39//! - [Client Credentials - Client Certificate](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow#second-case-access-token-request-with-a-certificate)
40//! - [Resource Owner Password Credentials](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth-ropc)
41
42#[macro_use]
43extern crate serde;
44#[macro_use]
45extern crate strum;
46#[macro_use]
47extern crate lazy_static;
48
49pub(crate) mod oauth_serializer;
50
51pub(crate) mod identity;
52
53#[cfg(feature = "interactive-auth")]
54pub mod interactive;
55
56pub(crate) mod internal {
57    pub use crate::oauth_serializer::*;
58}
59
60pub mod extensions {
61    pub use crate::oauth_serializer::*;
62}
63
64pub use crate::identity::*;
65pub use graph_core::{crypto::GenPkce, crypto::ProofKeyCodeExchange};
66pub use jsonwebtoken::{Header, TokenData};