OAuth1 SQL Server Reference Documentation
OAuth1
Current Version: 11.6.0
Chilkat.OAuth1
Generate the OAuth 1.0 signature and related authentication values from
the HTTP method, request URL, credentials, token, nonce, and timestamp.
Produce the value to send in the HTTP
Generate a URL that includes the OAuth 1.0 query parameters when the API
expects authentication data in the request URL.
Add or remove request-specific name/value parameters that must be
included in the normalized parameter string and signature calculation.
Sign with
Inspect the exact Generate OAuth 1.0 signatures, authorization headers, and signed request URLs.
Chilkat.OAuth1 builds the signed OAuth 1.0 authentication data
needed for APIs that still require OAuth 1.0 request signing. It can generate
the signature base string, HMAC key, signature, URL-encoded signature,
normalized signed parameter string, Authorization header, and generated URL
containing OAuth query parameters. It supports consumer credentials, access
tokens, nonce and timestamp generation, extra signed parameters, optional
realm handling, HMAC-SHA1, HMAC-SHA256, RSA-SHA1, and RSA-SHA256 signing.
OAuth 1.0 signing
Authorization header
Authorization header
when OAuth parameters should be supplied as a header.
Signed URL output
Extra signed parameters
HMAC or RSA signatures
HMAC-SHA1, HMAC-SHA256,
RSA-SHA1, or RSA-SHA256, with RSA private keys
supplied by SetRsaKey.
Debuggable signing details
BaseString, HmacKey,
QueryString, Signature, and
EncodedSignature used to build the OAuth request.
OauthMethod and OauthUrl, provide the consumer
key and secret, set any token and token secret, generate or assign
Nonce and Timestamp, add request parameters with
AddParam, then call Generate. Use
AuthorizationHeader when sending OAuth data in an HTTP header, or
GeneratedUrl when the signed OAuth parameters should be placed
in the URL.
OauthUrl to the base request URL without query parameters.
Add query parameters separately with AddParam so they are
included correctly in the OAuth 1.0 signature calculation.
Object Creation
DECLARE @hr int
DECLARE @oAuth1 int
EXEC @hr = sp_OACreate 'Chilkat.OAuth1', @oAuth1 OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- ... use @oAuth1 ...
EXEC @hr = sp_OADestroy @oAuth1T-SQL uses the Chilkat ActiveX through the OLE Automation stored procedures. They must be enabled once on the server (EXEC sp_configure 'Ole Automation Procedures', 1; RECONFIGURE;), and the Chilkat ActiveX registered must match the bitness of the SQL Server instance (64-bit for a 64-bit SQL Server). To bind to a specific major version of Chilkat, append the major version number to the ProgID, such as sp_OACreate 'Chilkat.OAuth1.11' for Chilkat v11.*.*.
sp_OACreate returns an object token (an int) that is passed as the first argument of every sp_OAMethod, sp_OAGetProperty and sp_OASetProperty call, and released with sp_OADestroy. Objects returned by methods (such as an HttpResponse or JsonObject) are also tokens received through an int OUT parameter; they must likewise be destroyed, and the OUT parameter is NULL when the method fails to return an object. Objects passed as arguments are passed by their token. When an OLE Automation procedure itself fails (non-zero @hr), sp_OAGetErrorInfo describes the error.
Data types: strings are nvarchar(4000); integers, booleans (1 or 0) and object tokens are int; dates are datetime. In the signatures on this page, @success, @iResult, @sResult and the like are the OUT variables receiving a method's return value, @iValue / @sValue receive or supply a property value, and the remaining @ variables are the method's arguments in order.
A string returned through an OUT parameter is limited to 4000 characters. For longer values, retrieve the result as a result set into a table variable instead of an OUT parameter, for example DECLARE @tmp TABLE (outputLine ntext) followed by INSERT INTO @tmp EXEC sp_OAGetProperty @oAuth1, 'LastErrorText'. See string length limitations for strings returned by sp_OAMethod calls.
Methods that pass or return raw byte arrays are not shown on this page, because varbinary(max) values cannot be exchanged through sp_OAMethod (see varbinary(max) limitation). Use the BinData-based alternatives (methods ending in Bd) or the base64 / hex string-encoded variants instead. Binary properties (such as LastBinaryResult) can be retrieved as a result set into a table variable, as shown in their signatures. Asynchronous (*Async) methods and event callbacks are not available from SQL Server.
Properties
AuthorizationHeader
The authorization header. This is what would be included in the Authorization HTTP request header if it is going to be used as the means for providing the OAuth1 authorization information.
topBaseString
This is the exact string that was signed. For example, if the signature method is HMAC-SHA1, the BaseString is the exact string that passed to the HMAC-SHA1. An application does not set the BaseString property. The BaseString is exposed as a property to allow for debugging and to see the exact string that is signed.
topConsumerKey
EXEC sp_OASetProperty @oAuth1, 'ConsumerKey', @sValue
The consumer key.
topConsumerSecret
EXEC sp_OASetProperty @oAuth1, 'ConsumerSecret', @sValue
The consumer secret.
topDebugLogFilePath
EXEC sp_OASetProperty @oAuth1, 'DebugLogFilePath', @sValue
If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.
Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.
Possible causes of hangs include:
- A timeout property set to 0, indicating an infinite timeout.
- A hang occurring within an event callback in the application code.
- An internal bug in the Chilkat code causing the hang.
EncodedSignature
The URL encoded representation of the Signature property
topGeneratedUrl
The URL that includes the OAuth1 query params.
topHmacKey
The exact HMAC key used to sign the BaseString. An application does not directly set the HmacKey. The HmacKey property is read-only and is provided for debugging to see the exact HMAC key used to sign the BaseString. The HMAC key is composed from the consumer secret (if it exists) and the token secret (if it exists).
topLastBinaryResult
This property is mainly used in SQL Server stored procedures to retrieve binary data from the last method call that returned binary data. It is only accessible if Chilkat.Global.KeepBinaryResult is set to 1. This feature allows for the retrieval of large varbinary results in an SQL Server environment, which has restrictions on returning large data via method calls, though temp tables can handle binary properties.
LastErrorHtml
Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastErrorText
Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
LastErrorXml
Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastMethodSuccess
EXEC sp_OASetProperty @oAuth1, 'LastMethodSuccess', @iValue
Indicates the success or failure of the most recent method call: 1 means success, 0 means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.
LastStringResult
In SQL Server stored procedures, this property holds the string return value of the most recent method call that returns a string. It is accessible only when Chilkat.Global.KeepStringResult is set to TRUE. SQL Server has limitations on string lengths returned from methods and properties, but temp tables can be used to access large strings.
LastStringResultLen
The length, in characters, of the string contained in the LastStringResult property.
topNonce
EXEC sp_OASetProperty @oAuth1, 'Nonce', @sValue
The nonce.
topOauthMethod
EXEC sp_OASetProperty @oAuth1, 'OauthMethod', @sValue
The HTTP method, such as GET, POST, PUT, DELETE, or HEAD. Defaults to GET.
OauthUrl
EXEC sp_OASetProperty @oAuth1, 'OauthUrl', @sValue
The OAuth URL, such as http://echo.lab.madgex.com/echo.ashx. See http://bettiolo.github.io/oauth-reference-page/ to compare Chilkat results with another tool's results.
Note: The OAuthUrl should not include query parameters. For example, do not set the OAuthUrl equal to
https://rest.sandbox.netsuite.com/app/site/hosting/restlet.nl?script=165&deploy=1Instead, set OAuthUrl equal to
https://rest.sandbox.netsuite.com/app/site/hosting/restlet.nland then subsequently call AddParam for each query parameter. top
OauthVersion
EXEC sp_OASetProperty @oAuth1, 'OauthVersion', @sValue
The oauth_version. Defaults to 1.0. May be set to the empty string to exclude.
QueryString
Contains the normalized set of request parameters that are signed. This is a read-only property made available for debugging purposes.
topRealm
EXEC sp_OASetProperty @oAuth1, 'Realm', @sValue
The realm (optional).
topSignature
The generated base64 signature.
topSignatureMethod
EXEC sp_OASetProperty @oAuth1, 'SignatureMethod', @sValue
The signature method. Defaults to HMAC-SHA1. Other possible choices are HMAC-SHA256, RSA-SHA1, and RSA-SHA256 (or the equivalent RSA-SHA2).
Timestamp
EXEC sp_OASetProperty @oAuth1, 'Timestamp', @sValue
The timestamp, such as 1441632569.
Token
EXEC sp_OASetProperty @oAuth1, 'Token', @sValue
The token.
topTokenSecret
EXEC sp_OASetProperty @oAuth1, 'TokenSecret', @sValue
The token secret
topUncommonOptions
EXEC sp_OASetProperty @oAuth1, 'UncommonOptions', @sValue
This is a catch-all property to be used for uncommon needs. This property defaults to the empty string and should typically remain empty.
Can be set to a list of the following comma separated keywords:
INCLUDE_REALM- Introduced in v9.5.0.85. Include the Realm in the signature calculation and outputs.
VerboseLogging
EXEC sp_OASetProperty @oAuth1, 'VerboseLogging', @iValue
If set to 1, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is 0. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.
Version
Methods
AddParam
Adds an extra name/value parameter to the OAuth1 signature.
Returns 1 for success, 0 for failure.
Generate
Generate the signature based on the property settings. Input properties are OauthVersion, OauthMethod, Url, ConsumerKey, ConsumerSecret, Token, TokenSecret, Nonce, and Timestamp. Properties set by this method include: BaseString, Signature, HmacKey, EncodedSignature, QueryString, GeneratedUrl, andAuthorizationHeader.
Returns 1 for success, 0 for failure.
GenNonce
Generates a random nonce numBytes in length and sets the Nonce property to the hex encoded value.
Returns 1 for success, 0 for failure.
topGenTimestamp
RemoveParam
SetRsaKey
Sets the RSA key to be used when the SignatureMethod is set to RSA-SHA1 or RSA-SHA2.
Returns 1 for success, 0 for failure.
top