get_token | R Documentation |
Retrieve a fresh waterinfo token. A token is not required to get started, see Details section for more information.
get_token( client = NULL, client_id = NULL, client_secret = NULL, token_url = "http://download.waterinfo.be/kiwis-auth/token" ) is.expired(token) expires.in(token)
client |
base64 encoded client containing the client id and client secret, seperated by : |
client_id |
client id string |
client_secret |
client secret string |
token_url |
url to get the token from |
token |
a token object |
Notice you do not need to get a token right away to download data. For limited and irregular downloads, a token will not be required. The amount of data downloaded from waterinfo.be is limited via a credit system. When you require more extended data requests, request a download token.
Either client or client_id and client_secret need to be passed as arguments. If provided, client is always used. Tokens remain valid for 24 hours, after which a fresh one must be acquired. To limit load on the server, token objects should be reused as much as possible until expiration in stead of creating fresh ones for each call.
The client_id and client_secret provided in the examples are for test purposes, get your very own client via hydrometrie@waterinfo.be.
An object of class token containing the token string with the token_url, token type and moment of expiration as attributes.
# Get token via client_id and client_secret client_id <- '32dceece-826c-4b98-9c2d-b16978f0ca6a' client_secret <- '4ada871a-9528-4b4d-bfd5-b570ce8f4d2d' my_token <- get_token(client_id = client_id,client_secret = client_secret) print(my_token) # get token via client client <- paste0('MzJkY2VlY2UtODI2Yy00Yjk4LTljMmQtYjE2OTc4ZjBjYTZhOjRhZGE4', 'NzFhLTk1MjgtNGI0ZC1iZmQ1LWI1NzBjZThmNGQyZA==') my_token <- get_token(client = client) print(my_token) is.expired(my_token) expires.in # Use the token when requesting for data (i.e. get_* functions), e.g. get_stations(variable_name = "verdamping_monteith", token = my_token)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.