Nothing
#' Get a 2-Legged Token for Authentication.
#'
#' Get a 2-legged token for OAuth-based authentication to the AutoDesk
#' Platform Services (APS).
#' @param id A string. Client ID for the app generated from the AutoDesk Dev
#' Portal.
#' @param secret A string. Client Secret for the app generated from the AutoDesk
#' Dev Portal.
#' @param scope A string. Space-separated list of required scopes. May be
#' \code{user-profile:read}, \code{data:read}, \code{data:write},
#' \code{data:create}, \code{data:search}, \code{bucket:create},
#' \code{bucket:read}, \code{bucket:update}, \code{bucket:delete},
#' \code{code:all}, \code{account:read}, \code{account:write}, or a
#' combination of these.
#' @return An \code{aps_token} object containing the \code{access_token},
#' \code{token_type}, \code{expires_in}, and \code{expires_at}. The token can
#' be passed directly to other AutoDeskR functions. Use
#' \code{\link{is_expired}} to check whether the token needs refreshing.
#' Legacy access via \code{resp$content$access_token} continues to work.
#' @examples
#' \dontrun{
#' tok <- getToken(id = Sys.getenv("client_id"), secret = Sys.getenv("client_secret"),
#' scope = "data:write data:read")
#' myToken <- tok$access_token
#' is_expired(tok)
#' }
#' @import httr2
#' @import jsonlite
#' @export
getToken <- function(id = NULL, secret = NULL, scope = "data:write data:read") {
if (is.null(id)) stop("id is null")
if (is.null(secret)) stop("secret is null")
if (is.null(scope)) stop("scope is null")
url <- 'https://developer.api.autodesk.com/authentication/v2/token'
resp <- aps_request(url) |>
req_body_form(
client_id = id,
client_secret = secret,
grant_type = "client_credentials",
scope = scope
) |>
aps_perform()
parsed <- resp_body_json(resp, simplifyVector = FALSE)
new_aps_token(parsed, url, resp)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.