Skip to content

Commit

Permalink
Check arguments to oauth_service_token.
Browse files Browse the repository at this point in the history
Fixes #282
  • Loading branch information
hadley committed Dec 18, 2015
1 parent bdafe6d commit ffd9f9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
@@ -1,5 +1,8 @@
# httr 1.0.0.9000

* `oauth_service_token()` checks that its arguments are the correct types
(#282).

* httr no longer bundles `cacert.pem`, and instead it relies on the bundle in
openssl. This bundle is only used a last-resort on windows with R <3.2.0.

Expand Down
7 changes: 7 additions & 0 deletions R/oauth-token.r
Expand Up @@ -253,6 +253,13 @@ Token2.0 <- R6::R6Class("Token2.0", inherit = Token, list(
#' token <- oauth_service_token(endpoint, secrets, scope)
#' }
oauth_service_token <- function(endpoint, secrets, scope = NULL) {
if (!is.oauth_endpoint(endpoint))
stop("`endpoint` must be an OAuth endpoint", call. = FALSE)
if (!is.list(secrets))
stop("`secrets` must be a list.", call. = FALSE)
if (!is.null(scope) && !(is.character(scope) && length(scope) == 1))
stop("`scope` must be a length 1 character vector.", call. = FALSE)

TokenServiceAccount$new(
endpoint = endpoint,
secrets = secrets,
Expand Down

0 comments on commit ffd9f9f

Please sign in to comment.