Learn R Programming

ROAuth (version 0.9.1)

OAuth-class: Class "OAuth": A class to manage OAuth authentication

Description

Class OAuth wraps and handles OAuth handshakes and signatures for the user within R

Arguments

Extends

All reference classes extend and inherit methods from "envRefClass".

Details

The OAuth class is currently implemented as a reference class. An instance of a generator for this class is provided as a convenience to the user as it is configured to handle most standard cases. To access this generator, use the object OAuthFactory. See the examples section below for an example of how to instantiate an object of class OAuth.

In almost all cases, saving an OAuth object after handshake and loading it into future sessions will allow it to remain authorized without needing any manual intervention that might have been performed initially, such as the PIN step with Twitter authentication. The needsVerifier argument is optional and defaults to TRUE. In almost all cases, the default should be used, the option is primarily provided to enable the examples as the keys provided by the examples are already signed. If you feel that you're in a situation where this should be set to FALSE, it's best to double check this.

The signMethod to the handshake method tells the system which OAuth signature hash to use, one of HMAC for HMAC-SHA1 (default), RSA for RSA-SHA1 (not implemented), or text for plaintext.

The customHeader argument to OAuthRequest can be used to pass additional HTTP header commands to the underlying request.

The curl arguments can be used to provide a custom curl header, defaulting to a generic getCurlHandle call.

References

liboauth: http://liboauth.sourceforge.net/

See Also

setRefClass

Examples

Run this code
## This example uses a test case from liboauth and the
   ## keys are already pre-signed.  This is an example of
   ## one of the few times \code{needsVerifier} would be \code{FALSE}.
  reqURL <- "http://term.ie/oauth/example/request_token.php"
   accessURL <- "http://term.ie/oauth/example/access_token.php"
   authURL <- "NORMALLY YOU NEED THIS"
   cKey <- "key"
   cSecret <- "secret"
   testURL <- "http://term.ie/oauth/example/echo_api.php?method=foo bar"

   credentials <- OAuthFactory$new(consumerKey=cKey,
                                   consumerSecret=cSecret,
                                   requestURL=reqURL,
				   accessURL=accessURL,
				   authURL=authURL,
                                   needsVerifier=FALSE)
   credentials$handshake()
   ## the GET isn't strictly necessary as that's the default
   credentials$OAuthRequest(testURL, "GET")

Run the code above in your browser using DataLab