Reports name and Canvas login ID for the current authenticated user, the Canvas domain and the first bit of the token.
Arguments
- .token
Authentication token. Defaults to
cnvs_token().- .api_url
Canvas domain URL. Used if
endpointjust contains a path. Defaults toCANVAS_DOMAINenvironment variable if set.- .send_headers
Named character vector of header field values (except
Authorization, which is handled via.token). This can be used to override or augment the defaultUser-Agentheader:"https://github.com/cwickham/cnvs".
Details
Your Canvas domain is the address of your organization's Canvas site, e.g.
https://oregonstate.instructure.com/. Set this via the CANVAS_DOMAIN
environment variable or pass it to .api_url.
Get a personal access token for your Canvas domain from
{CANVAS_DOMAIN}/profile/settings. The token itself is a string of
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 environment variables CANVAS_API_TOKEN
and CANVAS_DOMAIN with these values in their .Renviron file. Add
lines that look like these, substituting your domain and token:
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 cnvs_whoami() to confirm
success.
To get complete information on the authenticated user, call
cnvs("/api/v1/users/self").