cnvs_whoami: Info on current Canvas user, domain and token

Description Usage Arguments Details Value Examples

View source: R/whoami.R

Description

Reports name and Canvas login ID for the current authenticated user, the Canvas domain and the first bit of the token.

Usage

1
cnvs_whoami(.token = NULL, .api_url = NULL, .send_headers = NULL)

Arguments

.token

Authentication token. Defaults to CANVAS_API_TOKEN environment variable, if set.

.api_url

Canvas domain. Used if endpoint just contains a path. Defaults to CANVAS_DOMAIN environment variable, if set.

.send_headers

Named character vector of header field values (excepting Authorization, which is handled via .token). This can be used to override or augment the defaults, which are as follows: the Accept field defaults to "application/json", the User-Agent field defaults to "https://github.com/cwickham/cnvs", and the Content-Type defaults to "application/json".

Details

Your canvas domain is the address of your organizations' canvas site, e.g. https://oregonstate.instructure.com/, provide this to .api_url.

Get a personal access token for your Canvas domain from {CANVAS_DOMAIN/profile/settings}. The token itself is a string of 66 letters and digits. You can store it any way you like and provide explicitly via the .token argument to cnvs().

However, many prefer to define an environments variable CANVAS_API_TOKEN, and CANVAS_DOMAIN, with these values in their .Renviron file. Add lines that looks like these, substituting your domain and token:

1
2
CANVAS_DOMAIN="https://canvas.instructure.com"
CANVAS_API_TOKEN= "mvvGbKyGK9n5T57qhEu8K1sNMt85OLoNGTepqd3v5NEcWMuxArSz5aaXppPjodr5eU"

Put a line break at the end! If you’re using an editor that shows line numbers, there should be (at least) three lines, where the third one is empty. Restart R for this to take effect. Call cmvs_whoami() to confirm success.

To get complete information on the authenticated user, call cnvs("/api/v1/user/self").

Value

A cnvs_response object, which is also a list.

Examples

1
2
3
4
5
6
7
8
## Not run: 
cnvs_whoami()

## explicit token + domain
cnvs_whoami(.token = "mvvGbKyGK9n5T57qhEu8K1sNMt85OLoNGTepqd3v5NEcWMuxArSz5aaXppPjodr5eU",
          .api_url = "https://canvas.instructure.com")

## End(Not run)

cwickham/cnvs documentation built on Oct. 20, 2020, 5:34 a.m.