Permalink
Browse files

updated dropboxauth() to fix issue #4

  • Loading branch information...
1 parent 85c66c5 commit b96e72a1059932bf0269833a84285c5e2a1f723e @karthik committed Oct 11, 2012
Showing with 27 additions and 23 deletions.
  1. +27 −23 R/dropbox_auth.r
View
@@ -36,28 +36,32 @@ setClass("DropboxCredentials", contains = "OAuthCredentials")
#' dropbox_token <- dropbox_auth('consumey_key', 'consumer_secret')
#' save(dropbox_token, file = 'dropbox_auth.rdata')
#'}
-dropbox_auth <- function(cKey = getOption("DropboxKey",
- stop("Missing Dropbox consumer key")), cSecret = getOption("DropboxSecret",
- stop("Missing Dropbox app secret")), curl = getCurlHandle(),
- ...) {
- reqURL <- "https://api.dropbox.com/1/oauth/request_token"
- authURL <- "https://www.dropbox.com/1/oauth/authorize"
- accessURL <- "https://api.dropbox.com/1/oauth/access_token/"
- dropbox_oa <- oauth(cKey, cSecret, reqURL, authURL, accessURL,
- obj = new("DropboxCredentials"))
- cred <- handshake(dropbox_oa, post = FALSE, verify = paste("Use the Web browser to grant permission to this code",
- "to access Dropbox on your behalf.\nWhen you see 'Success!', hit enter in R",
- sep = "\n"))
- if (TRUE) {
- cat("\n Dropbox authentication completed successfully.\n")
- }
- if (FALSE) {
- info <- OAuthRequest(dropbox_oa, "https://api.dropbox.com/1/account/info")
- OAuthRequest(dropbox_oa, "https://api-content.dropbox.com/1/files/dropbox/foo")
- OAuthRequest(dropbox_oa, "https://api-content.dropbox.com/1/files/dropbox/foo",
- httpheader = c(Range = "bytes=30-70"), verbose = TRUE)
- }
- return(cred)
+dropbox_auth <- function(cKey = getOption("DropboxKey",
+stop("Missing Dropbox consumer key")), cSecret = getOption("DropboxSecret",
+stop("Missing Dropbox app secret")), curl = getCurlHandle(...),
+..., .opts = list(...)) {
+reqURL <- "https://api.dropbox.com/1/oauth/request_token"
+authURL <- "https://www.dropbox.com/1/oauth/authorize"
+accessURL <- "https://api.dropbox.com/1/oauth/access_token/"
+
+if(!missing(curl) && length(.opts))
+curlSetOpt(.opts = .opts, curl = curl)
+dropbox_oa <- oauth(cKey, cSecret, reqURL, authURL, accessURL,
+obj = new("DropboxCredentials"))
+cred <- handshake(dropbox_oa, post = FALSE, verify = paste("Use the Web browser to grant permission to this code",
+"to access Dropbox on your behalf.\nWhen you see 'Success!', hit enter in R",
+sep = "\n"), curl = curl)
+if (TRUE) {
+cat("\n Dropbox authentication completed successfully.\n")
+}
+if (FALSE) {
+info <- OAuthRequest(dropbox_oa, "https://api.dropbox.com/1/account/info")
+OAuthRequest(dropbox_oa, "https://api-content.dropbox.com/1/files/dropbox/foo")
+OAuthRequest(dropbox_oa, "https://api-content.dropbox.com/1/files/dropbox/foo",
+httpheader = c(Range = "bytes=30-70"), verbose = TRUE)
+}
+return(cred)
}
# API documentation:
-# https://www.dropbox.com/developers/reference/api#request-token
+
+# https://www.dropbox.com/developers/reference/api#request-token

1 comment on commit b96e72a

I will test this tonight and let you know how it goes!

Please sign in to comment.