diff --git a/README.md b/README.md index 0b927de24..8301977af 100644 --- a/README.md +++ b/README.md @@ -72,8 +72,12 @@ 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 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; diff --git a/examples/PublicOAuthAuthentication.md b/examples/PublicOAuthAuthentication.md new file mode 100644 index 000000000..1b8b0dad9 --- /dev/null +++ b/examples/PublicOAuthAuthentication.md @@ -0,0 +1,25 @@ +```csharp +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); + + /* + * 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); + Console.WriteLine(m.Body); + } +} +```