Skip to Content

registerTwitterOAuth {twitteR}

Register OAuth credentials to twitter R session
Package: 
twitteR
Version: 
1.1.7

Description

This function is used to provide your OAuth access tokens to your twitter session. This will enable many bits of functionality as well as allow other commands to provide more options

Usage

getTwitterOAuth(consumer_key, consumer_secret)
registerTwitterOAuth(oauth)

Arguments

consumer_key
The consumer key supplied by Twitter
consumer_secret
The consumer secret supplied by Twitter
oauth
An object of class OAuth

Details

The getTwitterOAuth function is a wrapper around the call to OAuthFactory and registerTwitterOAuth, which will return the registered credentials. If your workflow is such that you save the credentials and register them in later R sessions, feel free to do this using registerTwitterOAuth

registerTwitterOAuth will store the OAuth argument in an environment which is then accessed throughout the package. When API calls are made, instead of going through RCurl they will go through the ROAuth package.

Three URLs will need to be used for the initial OAuth handshake, see the examples below.

Values

TRUE on success, otherwise an error will be thrown

See Also

OAuth

Examples

## Not run:
       ## A real example, but using a fictitious consumerkey and consumer
       ## secret - you'll need to supply your own
       reqURL <- "https://api.twitter.com/oauth/request_token"
       accessURL <- "http://api.twitter.com/oauth/access_token"
       authURL <- "http://api.twitter.com/oauth/authorize"
       consumerKey <- "12345pqrst6789ABCD"
       consumerSecret <- "abcd1234EFGH5678ijkl0987MNOP6543qrst21"
       twitCred <- OAuthFactory$new(consumerKey=consumerKey,
                                    consumerSecret=consumerSecret,
                                    requestURL=reqURL,
                                    accessURL=accessURL,
                                    authURL=authURL)
       twitCred$handshake()
       registerTwitterOAuth(twitCred)
    ## End(Not run)

Author(s)

Jeff Gentry

Documentation reproduced from package twitteR, version 1.1.7. License: Artistic-2.0

Comments

isomorphisms's picture

Also note that this doesn't function as written because twitCred <- OAuthFactory$new(... ... requestURL=reqURL, doesn't match the earlier definition which was of requestURL.

isomorphisms's picture

NB: You need to load require("ROAuth") first because twitteR doesn't automatically pull it in.