auth: Authentication configuration/setup

Description Usage Arguments See Also Examples

Description

Authentication configuration/setup

Usage

1
2
3
4
5
6
7
8
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_path, api_query, api_template, api

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
## 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_path(orgs, ropensci, events) %>%
#   api_oauth2(token = "<your token>") %>%
#   api_config(verbose())

# 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 = "afdafasdfs",
#      secret = "asdfasdfasfasfsdf",
#      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)

sckott/request documentation built on Aug. 11, 2018, 6:11 p.m.