Title: | Provides User Tokens for Access to ICES Web Services |
---|---|
Description: | Provides user tokens for ICES web services that require authentication and authorization. Web services covered by this package are ICES VMS database, the ICES DATSU web services, and the ICES SharePoint site <https://www.ices.dk/data/tools/Pages/WebServices.aspx>. |
Authors: | Colin Millar [aut, cre] |
Maintainer: | Colin Millar <[email protected]> |
License: | GPL-3 |
Version: | 1.1.0 |
Built: | 2024-12-09 05:44:36 UTC |
Source: | https://github.com/ices-tools-prod/icesConnect |
Deletes the token from the key ring.
clear_token(username = getOption("ices.username"))
clear_token(username = getOption("ices.username"))
username |
the ices username that you require a token for, Default: getOption("ices.username") |
no return value
## Not run: clear_token() ## End(Not run)
## Not run: clear_token() ## End(Not run)
Decodes the token to allow inspection of claims
Return the expiration date of the token
What user is this token for
decode_token(jwt = ices_token(), formatted = TRUE) token_expiration(jwt = ices_token()) token_user(jwt = ices_token())
decode_token(jwt = ices_token(), formatted = TRUE) token_expiration(jwt = ices_token()) token_user(jwt = ices_token())
jwt |
a javascript web token got by running |
formatted |
should formatted output be returned |
list of claims
POSIXct date time
string, user name
## Not run: decode_token() ## End(Not run) ## Not run: token_expiration() ## End(Not run) ## Not run: token_user() ## End(Not run)
## Not run: decode_token() ## End(Not run) ## Not run: token_expiration() ## End(Not run) ## Not run: token_user() ## End(Not run)
Get a url, optionally using an ICES authentication token
ices_get( url, retry = TRUE, quiet = FALSE, verbose = FALSE, content = TRUE, use_token = FALSE )
ices_get( url, retry = TRUE, quiet = FALSE, verbose = FALSE, content = TRUE, use_token = FALSE )
url |
the url to get. |
retry |
should the get request be retried if first attempt fails? default TRUE. |
quiet |
should all messages be suppressed, default FALSE. |
verbose |
should verbose output form the http request be returned? default FALSE. |
content |
should content be returned, or the full http reponse? default TRUE, i.e. content is returned by default. |
use_token |
should an authentication token be sent with the request? |
content or an http response.
sag_api
builds a SAG web service url.
icesSAG-package
gives an overview of the package.
## Not run: ices_get(sag_api("StockList", year = 2022)) ## End(Not run)
## Not run: ices_get(sag_api("StockList", year = 2022)) ## End(Not run)
Perform a get request to a url using a javascript web token for authentication
ices_get_jwt( url, username = NULL, retry = TRUE, quiet = FALSE, verbose = FALSE, jwt = NULL ) ices_post_jwt( url, body = list(), encode = "json", username = NULL, retry = TRUE, quiet = FALSE, verbose = FALSE, jwt = NULL ) ices_patch_jwt( url, body = list(), encode = "json", username = NULL, retry = TRUE, quiet = FALSE, verbose = FALSE, jwt = NULL ) ices_request_jwt( type = c("GET", "POST", "PATCH"), url, body = NULL, encode = c("multipart", "form", "json", "raw"), username = NULL, retry = TRUE, quiet = FALSE, verbose = FALSE, jwt = NULL )
ices_get_jwt( url, username = NULL, retry = TRUE, quiet = FALSE, verbose = FALSE, jwt = NULL ) ices_post_jwt( url, body = list(), encode = "json", username = NULL, retry = TRUE, quiet = FALSE, verbose = FALSE, jwt = NULL ) ices_patch_jwt( url, body = list(), encode = "json", username = NULL, retry = TRUE, quiet = FALSE, verbose = FALSE, jwt = NULL ) ices_request_jwt( type = c("GET", "POST", "PATCH"), url, body = NULL, encode = c("multipart", "form", "json", "raw"), username = NULL, retry = TRUE, quiet = FALSE, verbose = FALSE, jwt = NULL )
url |
the url to make the request to |
username |
the ices username to perform the request as, Default: getOption("ices.username") |
retry |
if initial request fails, should a retry be made, Default: TRUE |
quiet |
suppress informative messages to the console |
verbose |
should the http request return verbose output |
jwt |
option to supply a token bypassing the ices_token() route, if "" no token is used |
body |
optional body of request |
encode |
If the body is a named list, how should it be encoded? |
type |
the type of request to make, GET, POST or PATCH |
httr response object
ices_token
GET
,add_headers
,stop_for_status
,status_code
## Not run: # this function is interactive and asks the user for a password ices_request_jwt("GET", "https://taf.ices.dk/vms/api/gearwidths") ices_get_jwt("https://taf.ices.dk/vms/api/gearwidths") ## End(Not run)
## Not run: # this function is interactive and asks the user for a password ices_request_jwt("GET", "https://taf.ices.dk/vms/api/gearwidths") ices_get_jwt("https://taf.ices.dk/vms/api/gearwidths") ## End(Not run)
Stores a user token in the system keyring
ices_token(username = NULL, password = NULL, refresh = FALSE, ...)
ices_token(username = NULL, password = NULL, refresh = FALSE, ...)
username |
the ices username that you require a token for, Default: NULL, which results in getOption("ices.username") |
password |
the ices username that you require a token for, Default: NULL, which results in a dialogue box request for the password |
refresh |
should the token be refreshed to update new claims for example |
... |
not yet used |
character scalar, the token
## Not run: ices_token() ## End(Not run)
## Not run: ices_token() ## End(Not run)
Set the ICES user or logon name that will be used for requests
set_username(username)
set_username(username)
username |
the ices username you use to login to SharePoint for example. |
To set this permanently, add the line:
options(ices.username = "your ices user name")
to your '.Rprofile' file, see, usually '~/.Rprofile', see
Startup
for more information.
invisible value: the previous username that was set
set_username("myusername")
set_username("myusername")