Title: | R Interface For OAuth |
---|---|
Description: | Provides an interface to the OAuth 1.0 specification allowing users to authenticate via OAuth to the server of their choice. |
Authors: | Jeff Gentry <[email protected]>, Duncan Temple Lang <[email protected]> |
Maintainer: | Pablo Barbera <[email protected]> |
License: | Artistic-2.0 |
Version: | 0.9.6 |
Built: | 2025-03-04 02:46:06 UTC |
Source: | https://github.com/pablobarbera/roauth |
Class OAuth
wraps and handles OAuth handshakes and signatures
for the user within R
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. Use the
function save
to save the credential object to a file and then
load
in another R session to bring it back in - there should be
no reason to undergo another handshake by doing this.
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.
consumerKey
:The consumer key provided by your application
consumerSecret
:The consumer secret provided by your application
needsVerifier
:Whether or not this OAuth
needs
the verification step. Defaults to TRUE
handshakeComplete
:Whether or not the handshaking was successfully completed
requestURL
:The URL provided for retrieving request tokens
authURL
:The URL provided for authorization/verification purposes
accessURL
:The URL provided for retrieving access tokens
oauthKey
:For internal use
oauthSecret
:For internal use
verifier
:For internal use
signMethod
:For internal use
handshake(signMethod='HMAC', curl=getCurlHandle(), browseUrl=TRUE, ...)
:Performs an OAuth handshake using the
information provided. If browseUrl
is TRUE
, the browseURL
function will be called on
the authentication URL
isVerified()
:Returns the current verification status
OAuthRequest(URL, params=character(), method="GET",
customHeader=NULL, curl=getCurlHandle(), ...)
:Will sign the URL provided and make an
HTTP request using either POST
or GET
,
determined by method
, defaulting to GET
. NOTE: The
URL
argument will be run through URLencode
, so
doing this step beforehand might lead to bad behavior!
initialize(needsVerifier, ...)
:For internal use
All reference classes extend and inherit methods from
"envRefClass"
.
Jeff Gentry
liboauth: http://liboauth.sourceforge.net/
## 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}. ## Not run: 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") ## End(Not run)
## 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}. ## Not run: 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") ## End(Not run)