View source: R/validate_request.R
validate_request | R Documentation |
validate an API request by looking up its token
validate_request(json, needProjectID = TRUE, needAdmin = FALSE)
json |
named list with at least these items:
An authorization ticket is the cookie generated by Apache's mod-auth-tkt.
It is distinguished by including at least one '!' character, which tokens
never contain. If |
needProjectID |
logical; if TRUE, a projectID to which the user
has permission must be in |
needAdmin |
logical; if TRUE, the user must have userType="administrator" in order to use the entry point; default: FALSE |
If the request was valid, a list with these items:
userID integer user ID
projects integer vector of *all* project IDs user has permission to
projectID the projectID(s) specified in the request (and it is guaranteed the user has permission to them), present only if the user specified it.
userType character scalar; one of "administrator", "contributor"
isAdmin logical scalar; TRUE if user is an administrator.
If the request was not valid, a value of class "error" and suitable for return by a Rook app, which contains an appropriate error message. This value should be immediately returned by the caller.
So typical usage is like:
auth = validate_request(json, needProjectID=FALSE)
if (inherits(auth, "error")) return(auth)
projectID = auth$projectID
this function is meant for use inside Rook servers, such as
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.