From ef8d9a7d242c7e27924aa10e18542f4594fd077d Mon Sep 17 00:00:00 2001 From: Athira Sabu <102021496+AsabuHere@users.noreply.github.com> Date: Thu, 14 Nov 2024 11:21:45 +0530 Subject: [PATCH 1/8] Adding example for using public OAuth --- examples/PublicOAuthAuthentication.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 examples/PublicOAuthAuthentication.md diff --git a/examples/PublicOAuthAuthentication.md b/examples/PublicOAuthAuthentication.md new file mode 100644 index 000000000..2d493cbf2 --- /dev/null +++ b/examples/PublicOAuthAuthentication.md @@ -0,0 +1,19 @@ +using Twilio; +using Twilio.Credential; +using Twilio.Rest.Api.V2010.Account; + +//Find client id, client secret of the OAuth App +//Message sid in this example is the sid of any previously sent message +class Program +{ + static void Main(string[] args) + { + + CredentialProvider credentialProvider = new ClientCredentialProvider(CLIENT_ID, CLIENT_SECRET); + TwilioClient.Init(credentialProvider, ACCOUNT_SID); + + FetchMessageOptions fm = new FetchMessageOptions(MESSAGE_SID); + MessageResource m = MessageResource.Fetch(fm); + Console.WriteLine(m.Body); + } +} From ca7bf019db6a6ec6fba0ef975da92e31c58b2a26 Mon Sep 17 00:00:00 2001 From: Athira Sabu <102021496+AsabuHere@users.noreply.github.com> Date: Thu, 14 Nov 2024 11:23:10 +0530 Subject: [PATCH 2/8] Update PublicOAuthAuthentication.md --- examples/PublicOAuthAuthentication.md | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/PublicOAuthAuthentication.md b/examples/PublicOAuthAuthentication.md index 2d493cbf2..dea433c89 100644 --- a/examples/PublicOAuthAuthentication.md +++ b/examples/PublicOAuthAuthentication.md @@ -8,7 +8,6 @@ class Program { static void Main(string[] args) { - CredentialProvider credentialProvider = new ClientCredentialProvider(CLIENT_ID, CLIENT_SECRET); TwilioClient.Init(credentialProvider, ACCOUNT_SID); From 054d55c5cd47847b3eb5526e727a070985f0c14f Mon Sep 17 00:00:00 2001 From: Athira Sabu <102021496+AsabuHere@users.noreply.github.com> Date: Thu, 14 Nov 2024 11:28:24 +0530 Subject: [PATCH 3/8] Update PublicOAuthAuthentication.md --- examples/PublicOAuthAuthentication.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/PublicOAuthAuthentication.md b/examples/PublicOAuthAuthentication.md index dea433c89..c9478c910 100644 --- a/examples/PublicOAuthAuthentication.md +++ b/examples/PublicOAuthAuthentication.md @@ -10,6 +10,11 @@ class Program { CredentialProvider credentialProvider = new ClientCredentialProvider(CLIENT_ID, CLIENT_SECRET); TwilioClient.Init(credentialProvider, ACCOUNT_SID); + + /* + * Or use the following if accountSid is not required as a path parameter for an API or when setting accountSid in the API. + TwilioClient.init(new ClientCredentialProvider(CLIENT_ID, CLIENT_SECRET)); + */ FetchMessageOptions fm = new FetchMessageOptions(MESSAGE_SID); MessageResource m = MessageResource.Fetch(fm); From 89a16a1fc59ea8b223e3121251f50c1f04673d84 Mon Sep 17 00:00:00 2001 From: Athira Sabu <102021496+AsabuHere@users.noreply.github.com> Date: Thu, 14 Nov 2024 11:40:43 +0530 Subject: [PATCH 4/8] Update BearerTokenAuthentication.md --- examples/BearerTokenAuthentication.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/BearerTokenAuthentication.md b/examples/BearerTokenAuthentication.md index df532bb0e..60f691df0 100644 --- a/examples/BearerTokenAuthentication.md +++ b/examples/BearerTokenAuthentication.md @@ -13,7 +13,7 @@ class Program static void Main(string[] args) { - CredentialProvider credentialProvider = new ClientCredentialProvider(CLIENT_ID, CLIENT_SECRET); + CredentialProvider credentialProvider = new OrgsClientCredentialProvider(CLIENT_ID, CLIENT_SECRET); TwilioClient.Init(credentialProvider); Twilio.Base.ResourceSet accountList = null; From c0b01f0ceb254107bc5811398eead5a9b0393a2e Mon Sep 17 00:00:00 2001 From: Athira Sabu <102021496+AsabuHere@users.noreply.github.com> Date: Thu, 14 Nov 2024 11:42:57 +0530 Subject: [PATCH 5/8] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0b927de24..e17fe6b05 100644 --- a/README.md +++ b/README.md @@ -72,8 +72,11 @@ var message = MessageResource.Create( ); Console.WriteLine(message.Sid); ``` +## OAuth Feature for Twilio APIs +We are introducing Client Credentials Flow-based OAuth 2.0 authentication. This feature is currently in beta and its implementation is subject to change. -Examples on how to make rest calls with bearer token authentication is added [here](https://github.com/twilio/twilio-csharp/blob/orgs_api_uptake/examples/BearerTokenAuthentication.md) +API examples [here](https://github.com/twilio/twilio-csharp/blob/main/examples/PublicOAuthAuthentication.md) +Organisation API examples [here](https://github.com/twilio/twilio-csharp/blob/main/examples/BearerTokenAuthentication.md) ## Specify Region and/or Edge From e4051df37e519da1af70e0e58deba64e01898083 Mon Sep 17 00:00:00 2001 From: Athira Sabu <102021496+AsabuHere@users.noreply.github.com> Date: Thu, 14 Nov 2024 11:44:38 +0530 Subject: [PATCH 6/8] Update README.md From c0c725dc36d3b7c7a974e5f74e577468e04a078c Mon Sep 17 00:00:00 2001 From: Athira Sabu <102021496+AsabuHere@users.noreply.github.com> Date: Thu, 14 Nov 2024 11:45:01 +0530 Subject: [PATCH 7/8] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e17fe6b05..8301977af 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ Console.WriteLine(message.Sid); We are introducing Client Credentials Flow-based OAuth 2.0 authentication. This feature is currently in beta and its implementation is subject to change. API examples [here](https://github.com/twilio/twilio-csharp/blob/main/examples/PublicOAuthAuthentication.md) + Organisation API examples [here](https://github.com/twilio/twilio-csharp/blob/main/examples/BearerTokenAuthentication.md) ## Specify Region and/or Edge From 930a36c55d95dbcb45d68475f4da84f527da0758 Mon Sep 17 00:00:00 2001 From: Athira Sabu <102021496+AsabuHere@users.noreply.github.com> Date: Thu, 14 Nov 2024 11:45:53 +0530 Subject: [PATCH 8/8] Update PublicOAuthAuthentication.md --- examples/PublicOAuthAuthentication.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/PublicOAuthAuthentication.md b/examples/PublicOAuthAuthentication.md index c9478c910..1b8b0dad9 100644 --- a/examples/PublicOAuthAuthentication.md +++ b/examples/PublicOAuthAuthentication.md @@ -1,3 +1,4 @@ +```csharp using Twilio; using Twilio.Credential; using Twilio.Rest.Api.V2010.Account; @@ -21,3 +22,4 @@ class Program Console.WriteLine(m.Body); } } +```