Skip to content

Commit

Permalink
fix the invalid scope by adding .default (#1678)
Browse files Browse the repository at this point in the history
* fix the invalid scope by adding .default

Signed-off-by: David Justice <david@devigned.com>

* fix nightly warning causing build error

Signed-off-by: David Justice <david@devigned.com>

---------

Signed-off-by: David Justice <david@devigned.com>
  • Loading branch information
devigned authored Jun 17, 2024
1 parent ebb219b commit 8c4caa2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions sdk/data_cosmos/src/authorization_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ async fn generate_authorization(
fn scope_from_url(url: &Url) -> String {
let scheme = url.scheme();
let hostname = url.host_str().unwrap();
format!("{scheme}://{hostname}")
format!("{scheme}://{hostname}/.default")
}

/// This function generates a valid authorization string, according to the documentation.
Expand Down Expand Up @@ -368,6 +368,6 @@ mon, 01 jan 1900 01:00:00 gmt
fn scope_from_url_01() {
let scope =
scope_from_url(&Url::parse("https://.documents.azure.com/dbs/test_db/colls").unwrap());
assert_eq!(scope, "https://.documents.azure.com");
assert_eq!(scope, "https://.documents.azure.com/.default");
}
}
3 changes: 2 additions & 1 deletion sdk/iot_hub/examples/updatetwin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
println!("Updating device twin for device: {device_id}");

let service_client = ServiceClient::new_connection_string(iot_hub_connection_string, 3600)?;
let json: String = serde_json::from_str(&payload).expect("Invalid JSON");
let updated_twin = service_client
.update_device_twin(device_id)
.desired_properties(serde_json::from_str(&payload)?)
.desired_properties(json)
.await?;

println!("Received device twin: {updated_twin:?}");
Expand Down

0 comments on commit 8c4caa2

Please sign in to comment.