Skip to content

Commit

Permalink
Update crate versions for pre-release
Browse files Browse the repository at this point in the history
  • Loading branch information
sreeise committed Jan 6, 2024
1 parent 8f23c0d commit 8cea1f1
Show file tree
Hide file tree
Showing 12 changed files with 162 additions and 204 deletions.
13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[package]
name = "graph-rs-sdk"
version = "1.1.3"
version = "2.0.0-beta.0"
authors = ["sreeise"]
edition = "2021"
readme = "README.md"
license = "MIT"
repository = "https://github.com/sreeise/graph-rs-sdk"
description = "Rust SDK Client for Microsoft Graph and the Microsoft Graph Api"
description = "Rust SDK Client for Microsoft Graph and Microsoft Identity Platform"
homepage = "https://github.com/sreeise/graph-rs-sdk"

exclude = [
"test_files/*",
Expand Down Expand Up @@ -36,10 +37,10 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
url = "2"

graph-oauth = { path = "./graph-oauth", version = "1.0.3", default-features=false }
graph-http = { path = "./graph-http", version = "1.1.2", default-features=false }
graph-error = { path = "./graph-error", version = "0.2.2" }
graph-core = { path = "./graph-core", version = "0.4.1", default-features=false }
graph-oauth = { path = "./graph-oauth", version = "2.0.0-beta.0", default-features=false }
graph-http = { path = "./graph-http", version = "2.0.0-beta.0", default-features=false }
graph-error = { path = "./graph-error", version = "0.3.0-beta.0" }
graph-core = { path = "./graph-core", version = "2.0.0-beta.0", default-features=false }

# When updating or adding new features to this or dependent crates run
# cargo tree -e features -i graph-rs-sdk
Expand Down
43 changes: 27 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@
[![crates.io](https://img.shields.io/crates/v/graph-rs-sdk.svg)](https://crates.io/crates/graph-rs-sdk)
![Build](https://github.com/sreeise/graph-rs-sdk/actions/workflows/build.yml/badge.svg)

### Rust SDK Client for Microsoft Graph and the Microsoft Graph Api
### Rust SDK Client for Microsoft Graph and Microsoft Identity Platform (Microsoft Entra and personal account sign in)

### Available on [crates.io](https://crates.io/crates/graph-rs-sdk)

Features:

- Microsoft Graph V1 and Beta API Client
- Paging using Streaming, Channels, or Iterators.
- Microsoft Graph V1 and Beta API Client
- Paging using Streaming, Channels, or Iterators
- Upload Sessions, OData Queries, and File Downloads
- Microsoft Graph Identity Platform OAuth2 and OpenId Connect Client
- Auth Code, Client Credentials, Device Code, OpenId, X509 Certificates, PKCE
- Auth Code, Client Credentials, Device Code, OpenId
- X509 Certificates, PKCE
- Interactive Authentication
- Automatic Token Refresh

```toml
graph-rs-sdk = "1.1.3"
graph-rs-sdk = "2.0.0-beta.0"
tokio = { version = "1.25.0", features = ["full"] }
```

Expand Down Expand Up @@ -92,7 +93,7 @@ The crate can do both an async and blocking requests.

#### Async Client (default)

graph-rs-sdk = "1.1.3"
graph-rs-sdk = "2.0.0-beta.0"
tokio = { version = "1.25.0", features = ["full"] }

#### Example
Expand Down Expand Up @@ -124,7 +125,7 @@ async fn main() -> GraphResult<()> {
To use the blocking client use the `into_blocking()` method. You should not
use `tokio` when using the blocking client.

graph-rs-sdk = "1.1.3"
graph-rs-sdk = "2.0.0-beta.0"

#### Example
use graph_rs_sdk::*;
Expand Down Expand Up @@ -1004,6 +1005,17 @@ Support for:
- Device Code Polling
- Authorization Using Certificates | features = [`openssl`]

#### Detailed Examples:


- [Identity Platform Auth Examples](https://github.com/sreeise/graph-rs-sdk/tree/v2.0.0/examples/identity_platform_auth)
- [Auth Code Grant](https://github.com/sreeise/graph-rs-sdk/tree/v2.0.0/examples/identity_platform_auth/auth_code_grant)
- [OpenId]((https://github.com/sreeise/graph-rs-sdk/tree/v2.0.0/examples/identity_platform_auth/openid))
- [Client Credentials]((https://github.com/sreeise/graph-rs-sdk/tree/v2.0.0/examples/identity_platform_auth/client_credentials))
- [Url Builders For Flows Using Sign In To Get Authorization Code - Building Sign In Url](https://github.com/sreeise/graph-rs-sdk/tree/v2.0.0/examples/authorization_sign_in)
- [Interactive Auth Examples (feature = `interactive-auth`)]((https://github.com/sreeise/graph-rs-sdk/tree/v2.0.0/examples/identity_platform_auth))
- [Certificate Auth (feature = `openssl`)](https://github.com/sreeise/graph-rs-sdk/tree/v2.0.0/examples/certificate_auth)

There are two main types for building your chosen OAuth or OpenId Connect Flow.

- `PublicClientApplication`
Expand Down Expand Up @@ -1066,15 +1078,14 @@ async fn build_client(
authorization_code: &str,
client_id: &str,
client_secret: &str,
redirect_uri: &str,
redirect_uri: url::Url,
scope: Vec<&str>
) -> anyhow::Result<GraphClient> {
let mut confidential_client = ConfidentialClientApplication::builder(client_id)
.with_authorization_code(authorization_code) // returns builder type for AuthorizationCodeCredential
.with_client_secret(client_secret)
.with_scope(scope)
.with_redirect_uri(redirect_uri)
.unwrap()
.build();

let graph_client = Graph::from(confidential_client);
Expand All @@ -1099,7 +1110,7 @@ lazy_static! {
static ref PKCE: ProofKeyCodeExchange = ProofKeyCodeExchange::oneshot().unwrap();
}

fn authorization_sign_in_url(client_id: &str, redirect_uri: &str, scope: Vec<String>) -> anyhow::Result<Url> {
fn authorization_sign_in_url(client_id: &str, redirect_uri: url::Url, scope: Vec<String>) -> anyhow::Result<Url> {
Ok(AuthorizationCodeCredential::authorization_url_builder(client_id)
.with_scope(scope)
.with_redirect_uri(redirect_uri)
Expand All @@ -1111,14 +1122,14 @@ fn build_confidential_client(
authorization_code: &str,
client_id: &str,
client_secret: &str,
redirect_uri: &str,
redirect_uri: url::Url,
scope: Vec<String>,
) -> anyhow::Result<ConfidentialClientApplication<AuthorizationCodeCredential>> {
Ok(ConfidentialClientApplication::builder(client_id)
.with_auth_code(authorization_code)
.with_client_secret(client_secret)
.with_scope(scope)
.with_redirect_uri(redirect_uri)?
.with_redirect_uri(redirect_uri)
.with_pkce(&PKCE)
.build())
}
Expand Down Expand Up @@ -1208,7 +1219,7 @@ The example below uses the auth code grant.
First create the url where the user will sign in. After sign in the user will be redirected back to your app and
the authentication code will be in the query of the uri.
```rust
pub fn authorization_sign_in_url(client_id: &str, tenant: &str, redirect_uri: &str) -> Url {
pub fn authorization_sign_in_url(client_id: &str, tenant: &str, redirect_uri: url::Url) -> Url {
let scope = vec!["offline_access"];

AuthorizationCodeCredential::authorization_url_builder(client_id)
Expand All @@ -1227,13 +1238,13 @@ async fn build_client(
client_id: &str,
client_secret: &str,
scope: Vec<String>, // with offline_access
redirect_uri: &str,
redirect_uri: url::Url,
) -> anyhow::Result<GraphClient> {
let mut confidential_client = ConfidentialClientApplication::builder(client_id)
.with_auth_code(authorization_code) // returns builder type for AuthorizationCodeCredential
.with_client_secret(client_secret)
.with_scope(scope)
.with_redirect_uri(redirect_uri)?
.with_redirect_uri(redirect_uri)
.build();

let graph_client = GraphClient::from(&confidential_client);
Expand Down Expand Up @@ -1262,7 +1273,7 @@ async fn authenticate(
tenant_id: &str,
client_id: &str,
client_secret: &str,
redirect_uri: &str,
redirect_uri: url::Url,
scope: Vec<&str>,
) -> anyhow::Result<GraphClient> {
std::env::set_var("RUST_LOG", "debug");
Expand Down
Loading

0 comments on commit 8cea1f1

Please sign in to comment.