Learn R Programming

request (version 0.1.0)

auth: Authentication configuration/setup

Description

Authentication configuration/setup

Usage

api_simple_auth(.data, user, pwd, type = "basic")
api_oauth2(.data, token = NULL, app_name = NULL, key = NULL, secret = NULL, base_url = NULL, authorize = NULL, access = NULL)
api_oauth1(.data, token = NULL, app_name = NULL, key = NULL, secret = NULL, base_url = NULL, request = NULL, authorize = NULL, access = NULL)

Arguments

.data
Result of a call to api
user
user name
pwd
password
type
type of HTTP authentication. Should be one of the following types supported by Curl: basic, digest, digest_ie, gssnegotiate, ntlm, ntlm_vn, any. Default: "basic" (the most common type)
token
An OAuth token
app_name
An OAuth application name
key
An OAuth key
secret
An OAuth secret key
base_url
option url to use as base for request, authorize and access urls.
authorize
url to send client to for authorisation
access
url used to exchange unauthenticated for authenticated token.
request
url used to request initial (unauthenticated) token. If using OAuth2.0, leave as NULL.

See Also

Other dsl: api_body, api_config, api_error_handler, api_query, api

Examples

Run this code
## Not run: 
# # simple authentication (user/password)
# api('https://httpbin.org/basic-auth/user/passwd') %>%
#  api_simple_auth(user = "user", pwd = "passwd")
# ## different auth type
# # api('https://httpbin.org/basic-auth/user/passwd') %>%
# #  api_simple_auth(user = "user", pwd = "passwd", type = "gssnegotiate")
# 
# # OAuth setup
# ## using a token
# ### fill in your own token
# # api('https://api.github.com/') %>%
# #   api_oauth2(token = "<token>")
# 
# # OAuth2
# ## using a app name, key, and secret combination
# ### uses a OAuth app set up by Hadley Wickham, which you'll auth against
# # api('https://api.github.com/') %>%
# #   api_oauth2(app_name = "github", key = "56b637a5baffac62cad9",
# #       secret = "8e107541ae1791259e9987d544ca568633da2ebf",
# #       base_url = "https://github.com/login/oauth",
# #       authorize = "authorize", access = "access_token")
# 
# # OAuth1
# # api('https://api.twitter.com/1.1/statuses/home_timeline.json') %>%
# #  api_oauth1(app_name = "twitter", key = "TYrWFPkFAkn4G5BbkWINYw",
# #      secret = "qjOkmKYU9kWfUFWmekJuu5tztE9aEfLbt26WlhZL8",
# #      base_url = "https://api.twitter.com/oauth/",
# #      request = "request_token", authorize = "authenticate", access = "access_token")
# 
# # Request some data with oauth2 via Github
# ## put in your username and password
# # api('https://api.github.com/') %>%
# #  api_simple_auth(user = "<foo>", pwd = "<bar>")
# ## End(Not run)

Run the code above in your browser using DataLab