Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

C# Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(C#) Twitter PIN-Based Authorization (Step 2)

Demonstrates the 2nd step in Twitter PIN-based authorization using OAuth. A PIN should have already been obtained from Step 1. The PIN is the OAuth verifier used in combination with the consumer secret and consumer key to get the access token and token secret that will be used for subsequent Twitter requests (to do whatever the Twitter account owner has permitted your application to do..)

Note: The OAuth version 1 functionality demonstrated in this example is available in Chilkat v9.4.0 to be released approximately in mid-December 2012. Pre-releases are available upon request by sending email to support@chilkatsoft.com. (Please be sure to specify your programming language, operating system, framework, architecture, etc. to uniquely identify the build that is needed.)

Chilkat .NET Downloads

Chilkat .NET Assemblies

Chilkat for .NET Core

Chilkat for Mono

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

Chilkat.Http http = new Chilkat.Http();

http.OAuth1 = true;
http.OAuthConsumerKey = "my-consumer-key";
http.OAuthConsumerSecret = "my-consumer-secret";
http.OAuthVerifier = "the-PIN-obtained-from-Step1";

Chilkat.HttpRequest req = new Chilkat.HttpRequest();
Chilkat.HttpResponse resp = http.PostUrlEncoded("https://api.twitter.com/oauth/access_token",req);
if (http.LastMethodSuccess == false) {
    Debug.WriteLine(http.LastErrorText);
    return;
}

if (resp.StatusCode == 200) {

    // Get the access token and secret:

    string oauthToken = resp.UrlEncParamValue(resp.BodyStr,"oauth_token");
    Debug.WriteLine("Access token = " + oauthToken);

    string oauthTokenSecret = resp.UrlEncParamValue(resp.BodyStr,"oauth_token_secret");
    Debug.WriteLine("Token secret = " + oauthTokenSecret);

    // Your application may now perform operations on the 
    // Twitter account for whatever has been authorized.
    // To do so, prior to sending the HTTP request, 
    // set the OAuthToken and OAuthTokenSecret
    // properties, and also make sure to clear OAuthVerifier property:
    http.OAuthToken = oauthToken;
    http.OAuthTokenSecret = oauthTokenSecret;
    http.OAuthVerifier = "";

    // Now that the http object has valid property values
    // for OAuthConsumerKey, OAuthConsumerSecret,
    //  OAuthToken, and OAuthTokenSecret, it can send authenticated
    // Twitter requests to the user's Twitter account.

}
else {
    Debug.WriteLine(http.LastErrorText);
}


 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.