Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adding example for using public OAuth #769

Merged
merged 8 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion examples/BearerTokenAuthentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<Twilio.Rest.PreviewIam.Organizations.AccountResource> accountList = null;
Expand Down
25 changes: 25 additions & 0 deletions examples/PublicOAuthAuthentication.md
Original file line number Diff line number Diff line change
@@ -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);
}
}
```
Loading